Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

No worries, I actually was able to figure it out from a FAQ at 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: 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:


and it worked perfect

I'm not even annoyed to use strange syntax after thinking it was problems with my Sage install ;-)