On 04/05/2011 11:36 AM, Luca Beltrame wrote:
> Hello,
>
> I'm trying to find a way to replace columns in matrices and data frames. For 
> a 
> data frame, the equivalent in R would be:
>
> mydataf$Column <- some_vector
>
> How can this be done from rpy2 (2.1.9), given that rx2() is a function and 
> thus can't be used for assignments?
>
> Thanks in advance.
Hi,

the only way I've managed so far was to make the dataframe known in the
R environment and then do the operation through R code directly. I used
it for sorting, or re-ordering a column but it's pretty much the same
operation.

rpy2.robjects.globalenv["mydataf"] = mydataf
rpy2.robjects.globalenv["some_vector"] = some_vector
rpy2.robjects.r("mydataf$Column <- some_vector")

I'm almost convinced there must be a better way but I haven't found one yet.

Good luck and let me know if you find something,
Moritz

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to