Is there any easy syntax to extract a Row of a DataFrame (that contains only numeric
) within RCpp either as a part of a DataFrame class or as some other class?
Currently I have been doing the following:
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
}
...
}