#12010: Make it easy to convert R variables to Sage
---------------------------+------------------------------------------------
Reporter: kcrisman | Owner: tbd
Type: enhancement | Status: new
Priority: minor | Milestone: sage-4.8
Component: packages | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
---------------------------+------------------------------------------------
This was initially requested at
[http://ask.sagemath.org/question/807/converting-r-variables-to-sage this
ask.sagemath.org question].
Question:
{{{
If I have a bunch of notebook cells with R code using the %r method, is
there an easy way to grab the data as a varible in Python/Sage without
converting the whole thing to use r.command syntax?
}}}
My answer, which I think should now be wrapped somehow given that it got
three upvotes (a lot for ask.sagemath):
{{{
Victory! I knew this should be possible.
In the notebook:
%r
a <- c(1,2,3)
a
[1] 1 2 3
from sage.interfaces.r import RElement
b = RElement(r,'a')
c = b._sage_()
c
[1, 2, 3]
and then you can do stuff to c because it's not an RElement.
c[1] = 3
c
[1, 3, 3]
I don't know whether this is worth wrapping slightly better, or if that is
even possible. But hopefully this works for you!
}}}
Note that this will only work for things with a nice conversion - but
better than the current situation.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12010>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
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-trac?hl=en.