On Thu, 2008-10-16 at 10:55 -0400, laurent oget wrote:
> In Rpy 1 i c can do
> 
> >>> import rpy
> >>> d=dict(x=[1,2],y=[2,3])
> >>> rpy.set_default_mode(rpy.NO_CONVERSION)
> >>> df=rpy.r.as_data_frame(d)
> >>> df
> <Robj object at 0xb7cd1400>
> 
> and i can then use this dataframe as an argument for lm
> 
> Is there any way to do something similar in rpy2? For the moment the
> only thing I have found is to use an Environment and to copy my
> dictionary into it.

There are several ways.

The closest to yours, although not the safest one(*),
might be:

import rpy2.robjects as ro
d = dict(x = [1,2], y = [2,3])
dataf = ro.r['data.frame'](**d)


(*: not the safest one because python dictionaries do not conserve the
order, and because R list do not enforce unique names - using
rpy2.rlike.container.TaggedList and rpy2.robjects.RDataFrame intends to
be "safer")


L.

> 
> Laurent
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to