Hi, list
I would like to calculate the fitness of two histograms, so I tried
to use the chisq.test() in R through rpy2.
The python code I have is as follows:
-------------------
import rpy2.robjects as robjects
p1dist = [X1, X2, ... Xm]
p2dist = [Y1, Y2, ... Ym]
rp1dist = robjects.FloatVector(p1dist)
rp2dist = robjects.FloatVector(p2dist)
robjects.r['chisq.test'](rp1dist, rp2dist)
-------------------
Then I got the following error:
File "/usr/lib64/python2.6/site-packages/rpy2/robjects/__init__.py", in
__call__
res = super(RFunction, self).__call__(*new_args, **new_kwargs)
rinterface.RRuntimeError: Error in names(dimnames(x)) <- DNAME :
'names' attribute [62] must be the same length as the vector [2]
I also tried rpy_classic, so my code change to the follows:
--------------------
import rpy2.robjects as robjects
import rpy2.rpy_classic as rpy
rpy.set_default_mode(rpy.NO_CONVERSION)
p1dist = [X1, X2, ... Xm]
p2dist = [Y1, Y2, ... Ym]
rp1dist = robjects.FloatVector(p1dist)
rp2dist = robjects.FloatVector(p2dist)
robjects.r['chisq.test'](rp1dist, rp2dist)
-----------------
Then I got similar error:
File "/usr/lib64/python2.6/site-packages/rpy2/rpy_classic.py", line 214,
in __call__
res = self.__sexp(*args_r, **kwargs_r)
rinterface.RRuntimeError: Error in names(dimnames(x)) <- DNAME :
'names' attribute [62] must be the same length as the vector [2]
I feel this problem is due to my wrong use of the R vector, but I
can not find it. Any hints will be mostly appreciated!
Thanks a lot in advance!
Hao
--
Hao Fan, PhD
Department of Biopharmaceutical Sciences
Mission Bay, Byers Hall
1700 4th Street, Suite 501
University of California, San Francisco
San Francisco, CA 94158-2330
Tel +1 (415) 514-4258, 4232, 4233
Fax +1 (415) 514-4231, 4234
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list