【发布时间】:2014-06-24 15:26:50
【问题描述】:
是否有任何简单的语法可以在 RCpp 中提取 DataFrame 的行(仅包含 numeric)作为 DataFrame 类的一部分或其他一些类?
目前我一直在做以下事情:
DataFrame myFunc(DataFrame& x) {
...
// Suppose I need to get the 10th row
int nCols=x.size();
std::vector<double> y;
y.reserve(nCols);
for (int j=0; j<nCols;j++) {
y.push_back((as<vector<double> >(x[j]))[9]); // index in C++ starts at 0
}
...
}
【问题讨论】: