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

Kevin Ushey kevinushey at gmail.com
Fri Jul 11 02:14:49 CEST 2014


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
example, gives you to have a hint at what attributes you can poke at and
how.

Cheers,
Kevin


On Thu, Jul 10, 2014 at 5:09 PM, Chaomei Lo <chaomeilo at gmail.com> wrote:

> 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
>
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140710/3d904b9c/attachment.html>


More information about the Rcpp-devel mailing list