RLink`
RLink`

RNull

RNull[]     is RLink's representation of an R NULL object.
Details and OptionsDetails
  • RNull corresponds to the Wolfram Language's Null.
  • Unless you manually construct or otherwise work with the RLink internal form of expressions representing R objects, you are unlikely to be using this head.
  • Examples

    Basic Examples  (1)

    In[1]:=
    Click for copyable input

    The Wolfram Language's Null is interpreted as R NULL during conversion to RLink's internal representation:

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

    Of course, it also works in another direction:

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

    You can set a variable (or part of an expression, e.g. part of a list) to NULL:

    In[4]:=
    Click for copyable input

    Comparison to NULL does not really workit returns a logical vector of length 0:

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

    You can, however, test the type of the value stored in the test variable:

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

    The proper way to test for NULL is via the is.null built-in R function:

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

    Vectors of zero length are also considered NULL in R:

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

    For this reason, assigning NULL to a vector's element is an error:

    In[9]:=
    Click for copyable input
    Out[9]=
    In[10]:=
    Click for copyable input
    Out[10]=

    Assigning NULL to an element of a list is not an error, and effectively deletes that element from a list. Here is a test list:

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

    This will assign NULL to its second element:

    In[12]:=
    Click for copyable input

    This is equivalent to removal of that element from a list:

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

    In some sense, R NULL therefore combines the behavior of the Wolfram Language's Null and Sequence[].

    In[14]:=
    Click for copyable input

    See Also

    RList    RObject  RAttributes  RCode  RFunction  REnvironment  ToRForm  FromRForm

    Tutorials