On 25 June 2012 at 17:43, Antonio Piccolboni wrote: | Hi, | is there a a way to access a specific element of a data frame in Rcpp without | previous knowledge of the type of the columns? I see from RcppExamples that one | can do something like: | | // construct the data.frame object | Rcpp::DataFrame DF = Rcpp::DataFrame(Dsexp); | // and access each column by name | Rcpp::IntegerVector a = DF["a"]; | a[2] = 42; | | which accesses DF[2, "a"] using the R syntax. Unfortunately, I don't have the | advance knowledge that column "a" will be an integer. I am trying to write some | code that would work for any frame. Suggestions? Thanks
Well, C++ is a strongly-typed language. So eventually you need to assign to /some/ type. You can always try to test using the collection of macros in the R's C-level API as for example Rf_isInteger() and friends. Dirk -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
