You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Hmm, nice work; you always know how to make it easy!
So maybe this ticket should be about adding this type of example to the r? documentation, because I don't think there is much about using it in the notebook right now, but I bet a lot of people would like to know this.
Unless you can think of an even shorter or underscore-less syntax that would make sense for this...
This was initially requested at this ask.sagemath.org question.
Question:
My answer, which I think should now be wrapped somehow given that it got three upvotes (a lot for ask.sagemath):
Note that this will only work for things with a nice conversion - but better than the current situation.
Component: packages: standard
Keywords: R, r-project
Issue created by migration from https://trac.sagemath.org/ticket/12010
The text was updated successfully, but these errors were encountered: