This represents the vector of integers:
Out[1]= | |
Unless there are some extra attributes present in a given R vector, you can usually use a simpler and more familiar Mathematica notation, representing vectors as (possibly nested) lists, for all RLink-related operations, so the above would just be equivalent to:
The form involving is, however, more "fundamental", since all expressions are translated into this form before being sent to R, and from this form when obtained from R. The "direct translation" is done with the function ToRForm:
Out[3]= | |
You can also see how multidimensional arrays are formed:
Out[1]= | |
This represents an array of real numbers:
Out[1]= | |
Here is a string (character) array:
Out[1]= | |
A complex matrix:
Out[1]= | |
A logical vector:
Out[1]= | |
An array with missing elements:
Out[1]= | |
Note that vectors can only contain elements of the same native type. The RLink automatic type detection will interpret a list with elements of different types as an R list (RList), rather than an R vector:
Out[1]= | |
You can send your vectors to R in this form as well:
Out[1]= | |
In fact, this is the actual form used to send a vector to R, even when it is initially expressed in more succinct notation ({1,2,3} here).
Add more attributes (properties) to your vector:
Out[2]= | |
The result is expressed in Mathematica:
Out[3]= | |
Note the RObject head. In contrast to heads used for "internal" RLink representation of R objects, such as, RList, and RNull, the head RObject represents the "final" Mathematica-side version of an R object, being just a generic container. You can use ToRForm to see the "internal" representation, which involves , since the resulting object is still a vector:
Out[4]= | |