Mathematica's Null is interpreted as R NULL during conversion to RLink's internal representation:
| Out[2]= |  |
Of course, it also works in another direction:
| Out[3]= |  |
You can set a variable (or part of an expression, e.g. part of a list) to NULL:
Comparison to NULL does not really work—it returns a logical vector of length 0:
| Out[5]= |  |
You can, however, test the type of the value stored in the test variable:
| Out[6]= |  |
The proper way to test for NULL is via the is.null built-in R function:
| Out[7]= |  |
Vectors of zero length are also considered NULL in R:
| Out[8]= |  |
For this reason, assigning NULL to a vector's element is an error:
| Out[9]= |  |
| 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:
| Out[11]= |  |
This will assign NULL to its second element:
This is equivalent to removal of that element from a list:
| Out[13]= |  |
In some sense, R NULL therefore combines the behavior of Mathematica's Null and Mathematica's Sequence[].