I have this code
// [[Rcpp::export]]
void testDf(Rcpp::DataFrame pq)
{
Rcpp::NumericVector p = pq[1];
std::cout<<p[2]<<std::endl;
}
Which is the right way of accessing an element of virtual row of a particular column . But if I do this
// [[Rcpp::export]]
void testDf(Rcpp::DataFrame pq)
{
std::cout<<pq[1][2]<<std::endl;
}
It return to me an error that operator[] is ambiguous . But if we see, DataFrame is just a set of vectors. From the Data structure point of view DataFrame will hold pointers to set of vectors. So the [] operator will return me a pointer and I can further access the pointer's different element through dereferencing it. Please correct me if I am wrong. Just started with the awesome Rcpp package. I am having few theoretical questions like this. I will be grateful for the answers.