converting an R vector to a list

907 views
Skip to first unread message

ablondin

unread,
Apr 13, 2010, 10:23:01 AM4/13/10
to sage-support
Dear Sage community,
I'm trying to use the R interface (which means I have to learn R as
well) and it's not going too bad, but I have no idea how I can
transform an R object (a vector) to get the associated list. For
instance, if I type
sage: x = r.c([1,2,3])
sage: x
[1] 1 2 3
sage: list(x)
[[1] 1, [1] 2, [1] 3]

I would like the output not to be a list with R objects as its
elements, but simply a list. Is that possible ?

Thanks !

Alex

ablondin

unread,
Apr 13, 2010, 12:20:15 PM4/13/10
to sage-support
I answered myself.
It suffices to call sageobj on it.

sage: x = r.c([1,2,3])
sage: x
[1] 1 2 3
sage: list(x)
[[1] 1, [1] 2, [1] 3]

sage:
sage:
sage:
sage: sageobj(x)
[1, 2, 3]
sage: type(sageobj(x))
<type 'list'>

Thanks anyway !

rickhg12hs

unread,
Apr 13, 2010, 10:26:14 PM4/13/10
to sage-support
x.sage() works great too!

On Apr 13, 12:20 pm, ablondin <alexandre.blondin.ma...@gmail.com>
wrote:

Olivier Picard

unread,
Apr 14, 2010, 11:45:28 PM4/14/10
to sage-s...@googlegroups.com
I am using the fuction r.scan() because i need to read big data file,since read_table() or read_csv() is not recommended for those kind of data, witch function would be the best one, sageobj() or x.sage(), or would both do the job well, thanks in advance for you answer

--
To post to this group, send email to sage-s...@googlegroups.com
To unsubscribe from this group, send email to sage-support...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using "remove me" as the subject.



--
Olivier Picard
Reply all
Reply to author
Forward
0 new messages