ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 17 May 2012 15:26:30 -0500R through Sage giving errors: Error: object 'sage3' not foundhttps://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/I am trying to use R through Sage and I have read about how the interface works so I think I am entering in the right code.
I have tried this on two different computers and get the same errors.
One is an quad core 64 bit Ubuntu 10 guest on VMWare Workstation 7 with host Win 7
the other is a single core 32bit Ubuntu 12 pure Linux install
when I access R methods I get errors of the form:
Error: object 'sageX' not found
where X is a number between 0 and 3
examples:
r.read_csv(DATA+'transaction_data.csv',header=True)
Error: object 'sage2' not found
and
r.read_table(header=True, text = "a b 1 2 3 4")
Error: object 'sage3' not found
I did find a trac that seems to be related to the error I'm getting:
[http://trac.sagemath.org/sage_trac/ticket/839](http://trac.sagemath.org/sage_trac/ticket/839)
But this is from 4 years ago, this issue must have been taken care of by now right?
I'm using Sage 4.8
Let me know if you have any idea how to fix this or if there might be something I did wrong during the installation
DougWed, 16 May 2012 16:29:26 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/Answer by Dug_the_Math_Guy for <p>I am trying to use R through Sage and I have read about how the interface works so I think I am entering in the right code.
I have tried this on two different computers and get the same errors.
One is an quad core 64 bit Ubuntu 10 guest on VMWare Workstation 7 with host Win 7
the other is a single core 32bit Ubuntu 12 pure Linux install
when I access R methods I get errors of the form:</p>
<p>Error: object 'sageX' not found
where X is a number between 0 and 3</p>
<p>examples:</p>
<p>r.read_csv(DATA+'transaction_data.csv',header=True) <br/>
Error: object 'sage2' not found</p>
<p>and</p>
<p>r.read_table(header=True, text = "a b 1 2 3 4")
Error: object 'sage3' not found</p>
<p>I did find a trac that seems to be related to the error I'm getting:
<a href="http://trac.sagemath.org/sage_trac/ticket/839">http://trac.sagemath.org/sage_trac/ticket/839</a>
But this is from 4 years ago, this issue must have been taken care of by now right?
I'm using Sage 4.8</p>
<p>Let me know if you have any idea how to fix this or if there might be something I did wrong during the installation</p>
<p>Doug</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13588#post-id-13588No worries, I actually was able to figure it out from a FAQ at
[http://wiki.sagemath.org/R](http://wiki.sagemath.org/R)
There is a syntactical issue with using R through sage which apparently still hasn't been fixed in Sage 4.8 where you need to use single quotes to tell python to pass a string to R but then R expects a double quoted string, so you have to use single quotes around double quotes:
see: [http://trac.sagemath.org/sage_trac/ticket/2963](http://trac.sagemath.org/sage_trac/ticket/2963)
so my
r.read_table(header=True, text = "a b 1 2 3 4")
should be:
r.read_table(header=True, text = '"a b 1 2 3 4"')
and when I use that syntax it works!
I get:
[1] a b X1 X2 X3 X4
<0 rows> (or 0-length row.names)
just like in pure R
the other example works too:
r.read_csv(DATA+'transaction_data.csv',header=True)
but here I am using DATA as a python string variable that is the path to my data file attached to the Sage notebook
it needs the double quotes inside single quotes as well as the file name.
I just did
sage: print DATA
/home/math_guy/.sage/sage_notebook.sagenb/home/admin/1/data/
and just copy and pasted the path and filename into the hybrid syntax:
r.read_csv('"/home/math_guy/.sage/sage_notebook.sagenb/home/admin/1/data/transaction_data.csv"',header=True)
and it worked perfect
I'm not even annoyed to use strange syntax after thinking it was problems with my Sage install ;-)Thu, 17 May 2012 11:31:44 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13588#post-id-13588Comment by kcrisman for <p>No worries, I actually was able to figure it out from a FAQ at
<a href="http://wiki.sagemath.org/R">http://wiki.sagemath.org/R</a>
There is a syntactical issue with using R through sage which apparently still hasn't been fixed in Sage 4.8 where you need to use single quotes to tell python to pass a string to R but then R expects a double quoted string, so you have to use single quotes around double quotes:</p>
<p>see: <a href="http://trac.sagemath.org/sage_trac/ticket/2963">http://trac.sagemath.org/sage_trac/ticket/2963</a>
so my</p>
<p>r.read_table(header=True, text = "a b 1 2 3 4")
should be:</p>
<p>r.read_table(header=True, text = '"a b 1 2 3 4"')
and when I use that syntax it works!
I get: <br/>
[1] a b X1 X2 X3 X4
<0 rows> (or 0-length row.names)
just like in pure R</p>
<p>the other example works too:
r.read_csv(DATA+'transaction_data.csv',header=True)
but here I am using DATA as a python string variable that is the path to my data file attached to the Sage notebook
it needs the double quotes inside single quotes as well as the file name.
I just did</p>
<p>sage: print DATA</p>
<p>/home/math_guy/.sage/sage_notebook.sagenb/home/admin/1/data/
and just copy and pasted the path and filename into the hybrid syntax:</p>
<p>r.read_csv('"/home/math_guy/.sage/sage_notebook.sagenb/home/admin/1/data/transaction_data.csv"',header=True)</p>
<p>and it worked perfect</p>
<p>I'm not even annoyed to use strange syntax after thinking it was problems with my Sage install ;-)</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?comment=19772#post-id-19772I'm confused as to how this is different from the answer above, but anyway glad it works! Upvote for showing the wiki page, I'd never seen that one before.Thu, 17 May 2012 15:26:30 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?comment=19772#post-id-19772Answer by Dug_the_Math_Guy for <p>I am trying to use R through Sage and I have read about how the interface works so I think I am entering in the right code.
I have tried this on two different computers and get the same errors.
One is an quad core 64 bit Ubuntu 10 guest on VMWare Workstation 7 with host Win 7
the other is a single core 32bit Ubuntu 12 pure Linux install
when I access R methods I get errors of the form:</p>
<p>Error: object 'sageX' not found
where X is a number between 0 and 3</p>
<p>examples:</p>
<p>r.read_csv(DATA+'transaction_data.csv',header=True) <br/>
Error: object 'sage2' not found</p>
<p>and</p>
<p>r.read_table(header=True, text = "a b 1 2 3 4")
Error: object 'sage3' not found</p>
<p>I did find a trac that seems to be related to the error I'm getting:
<a href="http://trac.sagemath.org/sage_trac/ticket/839">http://trac.sagemath.org/sage_trac/ticket/839</a>
But this is from 4 years ago, this issue must have been taken care of by now right?
I'm using Sage 4.8</p>
<p>Let me know if you have any idea how to fix this or if there might be something I did wrong during the installation</p>
<p>Doug</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=12972#post-id-12972I forgot to mention: I am getting these errors through the notebook
Wed, 16 May 2012 16:31:49 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=12972#post-id-12972Comment by kcrisman for <p>I forgot to mention: I am getting these errors through the notebook</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?comment=19784#post-id-19784Luckily, this is orthogonal to notebook, the same would happen in command line.Wed, 16 May 2012 16:47:09 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?comment=19784#post-id-19784Answer by kcrisman for <p>I am trying to use R through Sage and I have read about how the interface works so I think I am entering in the right code.
I have tried this on two different computers and get the same errors.
One is an quad core 64 bit Ubuntu 10 guest on VMWare Workstation 7 with host Win 7
the other is a single core 32bit Ubuntu 12 pure Linux install
when I access R methods I get errors of the form:</p>
<p>Error: object 'sageX' not found
where X is a number between 0 and 3</p>
<p>examples:</p>
<p>r.read_csv(DATA+'transaction_data.csv',header=True) <br/>
Error: object 'sage2' not found</p>
<p>and</p>
<p>r.read_table(header=True, text = "a b 1 2 3 4")
Error: object 'sage3' not found</p>
<p>I did find a trac that seems to be related to the error I'm getting:
<a href="http://trac.sagemath.org/sage_trac/ticket/839">http://trac.sagemath.org/sage_trac/ticket/839</a>
But this is from 4 years ago, this issue must have been taken care of by now right?
I'm using Sage 4.8</p>
<p>Let me know if you have any idea how to fix this or if there might be something I did wrong during the installation</p>
<p>Doug</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13579#post-id-13579It just so happens that we have a few answers on [this ask.sagemath.org question](http://ask.sagemath.org/question/1415/is-there-more-documentation-about-how-to-call-r-in) for you. In this case something like
sage: a = r.read_table(header=True,text='"a b cd e f g\n 1 2 3 4 56 6"')
sage: a
a b cd e f g
1 1 2 3 4 56 6
sage: type(a)
<class 'sage.interfaces.r.RElement'>
could work. Using R keywords through Sage is tricky, though, it's true - go to that question and upvote the most useful answer!Wed, 16 May 2012 16:46:49 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13579#post-id-13579Answer by Dug_the_Math_Guy for <p>I am trying to use R through Sage and I have read about how the interface works so I think I am entering in the right code.
I have tried this on two different computers and get the same errors.
One is an quad core 64 bit Ubuntu 10 guest on VMWare Workstation 7 with host Win 7
the other is a single core 32bit Ubuntu 12 pure Linux install
when I access R methods I get errors of the form:</p>
<p>Error: object 'sageX' not found
where X is a number between 0 and 3</p>
<p>examples:</p>
<p>r.read_csv(DATA+'transaction_data.csv',header=True) <br/>
Error: object 'sage2' not found</p>
<p>and</p>
<p>r.read_table(header=True, text = "a b 1 2 3 4")
Error: object 'sage3' not found</p>
<p>I did find a trac that seems to be related to the error I'm getting:
<a href="http://trac.sagemath.org/sage_trac/ticket/839">http://trac.sagemath.org/sage_trac/ticket/839</a>
But this is from 4 years ago, this issue must have been taken care of by now right?
I'm using Sage 4.8</p>
<p>Let me know if you have any idea how to fix this or if there might be something I did wrong during the installation</p>
<p>Doug</p>
https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13518#post-id-13518another clue:
the problem appear to be with Sage's interface to R since when I run the notebook in the pure R mode and alter the syntax of the latter comment above I don't get an error ( even though it looks like I got 0 rows in my table since I apparently need to inform R where my EOL's are ):
read.table(header=TRUE, text = "a b 1 2 3 4")
[1] a b X1 X2 X3 X4
<0 rows> (or 0-length row.names)
Wed, 16 May 2012 16:42:14 -0500https://ask.sagemath.org/question/8975/r-through-sage-giving-errors-error-object-sage3-not-found/?answer=13518#post-id-13518