Macaulay2 » Documentation
Packages » RInterface » RObject » new RObject from List
next | previous | forward | backward | up | index | toc

new RObject from List -- create an R vector from a list

Description

Converts a Macaulay2 List to an R vector using R's c function. The type of the resulting vector is determined by the elements:

i1 : RObject {true, false, true, false}

o1 = [1]  TRUE FALSE  TRUE FALSE

o1 : RObject of type logical
i2 : RObject {2, 4, 6, 8, 10}

o2 = [1]  2  4  6  8 10

o2 : RObject of type integer
i3 : RObject {0, 1/2, exp 1}

o3 = [1] 0.000000 0.500000 2.718282

o3 : RObject of type double
i4 : RObject apply(3, k -> exp(2*k*pi*ii/3))

o4 = [1]  1.0+0.0000000i -0.5+0.8660254i -0.5-0.8660254i

o4 : RObject of type complex
i5 : RObject {"foo", "bar", "baz"}

o5 = [1] "foo" "bar" "baz"

o5 : RObject of type character

When any elements are Option objects, the keys become names in R.

i6 : RObject {foo => 1, bar => 2}

o6 = foo bar 
       1   2 

o6 : RObject of type integer
i7 : RObject {foo => 1, 2, bar => 3}

o7 = foo     bar 
       1   2   3 

o7 : RObject of type integer

See also

Ways to use this method:


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/RInterface/doc/objects.m2:328:0.