本文整理汇总了C++中AbstractMatrix::writeVariableName方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractMatrix::writeVariableName方法的具体用法?C++ AbstractMatrix::writeVariableName怎么用?C++ AbstractMatrix::writeVariableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractMatrix
的用法示例。
在下文中一共展示了AbstractMatrix::writeVariableName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_all_varnames_R
// !!!
SEXP set_all_varnames_R(SEXP s, SEXP names) {
// testDbg << "set_all_varnames_R"<<endl;
AbstractMatrix * p = getAbstractMatrixFromSEXP(s);
if (p == NULL) {
error_R("pointer is NULL\n");
return R_NilValue;
}
// R_len_t nvars = (R_len_t) 0;
unsigned long nvars = 0;
try {
nvars = p->getNumVariables();
} catch (int errcode) {
error_R("can not p->getNumVariables()\n");
return R_NilValue;
}
// check that length of SEXP names is the same!!!
for (unsigned long i = 0; i < nvars; i++) {
string varname = CHAR(STRING_ELT(names,i));
try {
p->writeVariableName(i,FixedChar(varname));
} catch (int errcode) {
error_R("can not set variable name for variable %ul\n",i);
return R_NilValue;
}
}
SEXP ret;
PROTECT(ret = allocVector(LGLSXP, 1));
LOGICAL(ret)[0] = TRUE;
UNPROTECT(1);
return ret;
}
示例2: set_all_varnames_R
// !!!
SEXP set_all_varnames_R(SEXP s, SEXP names) {
CHECK_PTR(s);
AbstractMatrix * p = (AbstractMatrix*) R_ExternalPtrAddr(s);
if (p == NULL) {
error_R("pointer is NULL\n");
return R_NilValue;
}
R_len_t nvars = (R_len_t) 0;
try {
nvars = p->getNumVariables();
} catch (int errcode) {
error_R("can not p->getNumVariables()\n");
return R_NilValue;
}
// check that length of SEXP names is the same!!!
for (unsigned long int i = 0; i < nvars; i++) {
std::string varname = CHAR(STRING_ELT(names, i));
try {
p->writeVariableName(i, fixedchar(varname));
} catch (int errcode) {
error_R("can not set variable name for variable %ul\n", i);
return R_NilValue;
}
}
SEXP ret;
PROTECT(ret = allocVector(LGLSXP, 1));
LOGICAL(ret)[0] = TRUE;
UNPROTECT(1);
return ret;
}