Hi,

I just downloaded and installed v4.7 of Sage on Mac OS X 10.6.8.

I really like the application and appreciate all of the hard work the
Sage team has done to produce this great software package.

Lately, I have been trying to learn R and rpy2 for statistical
analyses.
Unfortunately, I have been experiencing some problems as I work
through the rpy2 documentation pages (http://rpy.sourceforge.net/rpy2/
doc-2.0/html/introduction.html#getting-started) from within Sage.

For instance, this simple worksheet input,

---------------------------------
import rpy2.robjects as robjects
piplus2 = robjects.r('pi') + 2
---------------------------------

generates the following error:

---------------------------------
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_7.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding:
utf-8 -*-\\n" +
_support_.preparse_worksheet_cell(base64.b64decode("cm9iamVjdHMucigncGknKSArIDI="),globals())
+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/private/var/folders/J3/J3WNYO+MFDW9+9Xg5-QGoE+++TI/-Tmp-/
tmp1hAhTO/___code___.py", line 3, in <module>
    exec compile(u"robjects.r('pi') + _sage_const_2 " + '\n', '',
'single')
  File "", line 1, in <module>

  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/rpy2/
robjects/__init__.py", line 263, in __add__
    res = r.get("c")(self, x)
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/rpy2/
robjects/__init__.py", line 419, in __call__
    new_args = [conversion.py2ri(a) for a in args]
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/rpy2/
robjects/__init__.py", line 93, in default_py2ri
    raise(ValueError("Nothing can be done for the type %s at the
moment." %(type(o))))
ValueError: Nothing can be done for the type <type
'sage.rings.integer.Integer'> at the moment.
---------------------------------


I then switched to r mode on the worksheet and typed a set of R
commands given in the same rpy2 documentation:

---------------------------------
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
anova(lm.D9 <- lm(weight ~ group))
summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept
---------------------------------


In this case, the following error resulted:

---------------------------------
Traceback (most recent call last):
  File "", line 1, in <module>

  File "/tmp/sage-mac-app/devel/sagenb/sagenb/misc/support.py", line
473, in syseval
    return system.eval(cmd, sage_globals, locals = sage_globals)
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/rpy2/
robjects/__init__.py", line 419, in __call__
    new_args = [conversion.py2ri(a) for a in args]
  File "/tmp/sage-mac-app/local/lib/python2.6/site-packages/rpy2/
robjects/__init__.py", line 93, in default_py2ri
    raise(ValueError("Nothing can be done for the type %s at the
moment." %(type(o))))
ValueError: Nothing can be done for the type <type 'dict'> at the
moment.
---------------------------------


Am I doing something wrong or is there some sort of 'casting' issue
between R, rpy2, and Sage?

Thank you for your help.

-Brad

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to