Re: [Rcpp-devel] retrieve the column names of Rcpp::DataFrame

2014-07-10 Thread Chaomei Lo
Thanks a lot for help. Kevin. You are correct, both df.attr("names") and df.names() work. Chaomei On Thu, Jul 10, 2014 at 5:14 PM, Kevin Ushey wrote: > df.attr("names") ? data.frames do not have a column names attribute. > Neither do matrices, for that matter, which have an (optional) `dimn

Re: [Rcpp-devel] retrieve the column names of Rcpp::DataFrame

2014-07-10 Thread Kevin Ushey
df.attr("names") ? data.frames do not have a column names attribute. Neither do matrices, for that matter, which have an (optional) `dimnames` attribute. Please see: http://gallery.rcpp.org/articles/setting-object-attributes/, and also try looking at what e.g. `attributes(data.frame(x=1))`, for ex

[Rcpp-devel] retrieve the column names of Rcpp::DataFrame

2014-07-10 Thread Chaomei Lo
I have a R data frame pass to the Rcpp function, for example in below- void myDataFrame(Rcpp::DataFrame df) { } I would need to know the column names first before I retrieve the data but df.colnames() does not work but the df.length() and df.nrows() work. Thanks for help ! Chaomei _