[Rcpp-devel] data.frame from R to C++?

Dirk Eddelbuettel edd at debian.org
Fri Apr 8 14:20:07 CEST 2011


On 8 April 2011 at 00:27, deqiang sun wrote:
| Hi all,
| 
| Suppose I want to read a csv file including TEXT and NUMBER fields in R by function read.table. 
| Is there a way to use the result in C++? Like the way I use in R, say, 2nd column is x[,2], 3rd row is x[3,].
| I have gone through the examples in RInside and did not find anything helpful.

You will want to look at _Rcpp_ not RInside for these things.  

It is also a good idea to check the mailing list archive. Here I quickly
search Google for "gmane rcpp-devel Rcpp::DataFrame" and found e.g.

http://article.gmane.org/gmane.comp.lang.r.rcpp/1205 
     -- returning a data.frame from R to C++

and a bunch more. 

But I think you can't pass an entire dataframe from R to C++ _as a single
object_ but it is easy to pass each column.  Have a look at the documentation
and the mailing list archives.

Dirk

| PS: Usually when I read a csv into C++ I would do splitting myself line by line and if I want to do operations between columns I need to write addition data structures. 
| 
| Thanks,
| Dsun
| 
| 
| 
| _______________________________________________
| 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

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list