<div dir="ltr">Thanks a lot for help. Kevin.<div><br></div><div>You are correct, both df.attr("names") and df.names() work. </div><div><br></div><div>Chaomei</div><div><br></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Jul 10, 2014 at 5:14 PM, Kevin Ushey <span dir="ltr"><<a href="mailto:kevinushey@gmail.com" target="_blank">kevinushey@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">df.attr("names") ? data.frames do not have a column names attribute. Neither do matrices, for that matter, which have an (optional) `dimnames` attribute.<br><br>Please see: <a href="http://gallery.rcpp.org/articles/setting-object-attributes/" target="_blank">http://gallery.rcpp.org/articles/setting-object-attributes/</a>, 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.<br>

<br>Cheers,<br>Kevin</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Thu, Jul 10, 2014 at 5:09 PM, Chaomei Lo <span dir="ltr"><<a href="mailto:chaomeilo@gmail.com" target="_blank">chaomeilo@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>I have a R data frame pass to the Rcpp function, for example in below-</div>
<div><br></div><div>void myDataFrame(Rcpp::DataFrame df) {</div>
<div>....</div><div>}</div><div><br></div><div>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.  </div>
<div><br></div><div>Thanks for help !</div><span><font color="#888888"><div>Chaomei</div><div><br></div><div><br></div><div> </div></font></span></div>
<br></div></div>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></blockquote></div><br></div>
</blockquote></div><br></div>