Ask Your Question

inter-mixing Sage and R

asked 2011-07-14 11:51:21 -0600

anonymous user


updated 2011-07-15 06:49:36 -0600

Updated: How well is compatibility with intermixing Sage code and R code? For instance, if I want to do:

f ="bar.txt", row.names = NULL, header=T, sep=";") calling some sage function and prints some output

but it didn't work as Sage can't find the corresponding R "table" method. But I do %r and just use "read.table(...)", it works flawlessly. But I can't use the pass the R timeseries to Sage list.

Is there a better way around this?

edit retag flag offensive close merge delete


parzan gravatar imageparzan ( 2011-07-15 00:07:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2011-07-29 08:46:08 -0600

kcrisman gravatar image

This may not completely answer your question, but note that dot methods in R become underscores in Sage.

sage:[tab]              r.read_csv          r.read_ftable
r.readBin           r.read_csv2         r.read_fwf
r.readChar          r.read_dcf          r.read_socket
r.readCitationFile  r.read_delim        r.read_table
r.readLines         r.read_delim2       r.read_table_url
r.read_DIF          r.read_fortran      r.readline
sage: r.read_table?
Definition:     r.read_table(self, *args, **kwds)
    read.table                package:utils                R Documentation

    Data Input


         Reads a file in table format and creates a data frame from it,
         with cases corresponding to lines and variables to fields in the


         read.table(file, header = FALSE, sep = "", quote = "\"'",
                    dec = ".", row.names, col.names,
           = !stringsAsFactors,
                    na.strings = "NA", colClasses = NA, nrows = -1,

I don't have your bar.txt, though, and unfortunately passing optional arguments can be tricky, sometimes calling for multiple levels of quotes, sometimes not. I've often used r.eval("R command") for that, like


which however is not ideal, but it gets the job done.

edit flag offensive delete link more


When I type "r.read_table?" or "r.read_csv?" I have an attribute error.

debian_economist gravatar imagedebian_economist ( 2016-08-24 10:20:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-07-14 11:51:21 -0600

Seen: 332 times

Last updated: Jul 29 '11