RLink`
RLink`

RObject

RObject[data,attributes]

represents a general R object, usually having a non-trivial set of attributes.

Details and OptionsDetails
  • RObject is a container that allows you to specify attributes for a given R object.
  • data should be any valid short form of an expression representing an R object in RLink.
  • attributes must have the form RAttributes["name1":> value1,], where values of attributes can be any R objects handled by RLink.
  • Examples

    Basic Examples  (4)

    In[1]:=
    Click for copyable input

    This constructs a list (vector) of random integers in R:

    In[1]:=
    Click for copyable input
    Out[1]=

    This makes a contingency table of the above data:

    In[2]:=
    Click for copyable input
    Out[2]=

    Since the corresponding R object (table) has non-trivial attributes, RObject was used to make it possible to include those.

    This constructs an R data frame out of the contingency table:

    In[1]:=
    Click for copyable input
    Out[1]=

    Here is the full internal form RLink uses to represent the above data frame:

    In[2]:=
    Click for copyable input
    Out[2]=

    As you can see, RObject is now gone, since heads used in the RLink internal representation of R objects (RVector and RList) can accommodate attributes.

    This creates a matrix:

    In[1]:=
    Click for copyable input
    Out[1]=

    Send it to R:

    In[2]:=
    Click for copyable input
    Out[2]=

    Assign another attribute to R's mat variable:

    In[3]:=
    Click for copyable input
    Out[3]=

    Get back a resulting R object:

    In[4]:=
    Click for copyable input
    Out[4]=

    Since now it has an attribute, RObject was used to represent it. You can also display its attributes:

    In[5]:=
    Click for copyable input
    Out[5]=

    Note that the "dim" attribute is implicit in the matrix representation in the short form, so its presence does not require the use of RObject. It is, however, explicitly present in the full form:

    In[6]:=
    Click for copyable input
    Out[6]=

    See Also

    RAttributes  ToRForm  FromRForm

    Tutorials