RDataFrame *is* a Python class.

There are many ways to cast it into a different data structure, if you 
wish to do so.

If going for a list of lists:
lolist = [[x for x in y] for y in dataf]

Note that going to a Python dictionary is not the most robust of the 
ideas (there might be several elements with the same name in an R list).
Going for a rpy2.rlike.container.TaggedList might be a better choice:

import rpy2.rlike.container.TaggedList as TaggedList
tglist = TaggedList(lolist, tags=[x for x in dataf.getnames()])


L.

PS: I see now that the __getindex__ method for RVectors should probably 
use R's "[" function (and likely make the conversion above unnecessary 
in many cases)




Carlos Jesus Anderson wrote:
> Hi, 
> 
> How may I convert an RDataFrame into Python objects? I used the read.table 
> function in R to read in data (from Python), but now I want to treat the 
> data as Python objects, like a dictionary or a set of lists. I don't want to 
> work with RVectors. 
> 
> Thanks, 
> 
> Carlos
> 
> 
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to