There seem to be differences in the behavior of data_frame when running
in rpy for R 2.6.0 and for R 2.6.1.
The following R code works for both versions of R but not in python:
x <- matrix(c(1.2, 3.5, 4.5,2.4, 3.2, 6.7), 3,2)
y <- c(4.5, 2.4, 3.7)
d <- data.frame(x=x, y=y)
lm("y~x.1+x.2", data=d)
Using rpy compiled for R 2.6.0, the following code works:
from rpy import r
from numpy import array, transpose
x = transpose(array([[1.2, 3.5, 4.5],[2.4, 3.2, 6.7]]))
y = array([4.5, 2.4, 3.7])
d = r.data_frame(x=x, y=y)
r.lm('y ~ x.1+x.2', data=d)
Using rpy compiled for R 2.6.1 I get the following error on the
'data_frame' call:
rpy.RException: Error in function (..., row.names = NULL, check.rows =
FALSE, check.names = TRUE, :
arguments imply differing number of rows: 3, 2
If I don't use the 'transpose' function, so that 'x' is a 2 x 3 array
(instead of 3 x 2), I get an error on the 'lm' call:
rpy.RException: Error in eval(expr, envir, enclos) : object "x.1" not found
Looking at the data_frame object 'd', in case of R 2.6.0 I have:
{'y': array([ 4.5, 2.4, 3.7]), 'x.1': [1.2, 3.5, 4.5], 'x.2':
[2.3999999999999999, 3.2000000000000002, 6.7000000000000002]}
But in case of R 2.6.1 the object has names composed from the values of
the array, and thus 'x.1' and 'x.2' cannot be found:
{'y': [4.5, 2.3999999999999999, 3.7000000000000002],
'x.c.1.2..3.5..4.5.': [1.2, 3.5, 4.5], 'x.c.2.4..3.2..6.7.':
[2.3999999999999999, 3.2000000000000002, 6.7000000000000002]}
Is there a way how to handle such cases in the same way for both
versions of R?
Thank you very much,
Hana Sevcikova
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list