represents an internal form of an R list in RLink.

Details and Options

  • The elements elems can be of any valid RLink object type.
  • attributes must have the form RAttributes["name1":>value1,...], where values of attributes can be any R objects handled by RLink.


Basic Examples  (9)

Like with RVector, most of the time, you will find it more convenient to use the short form of a list, rather than using RList directly. For example, a pair of an integer and a real number can be represented simply as:

Yo can use ToRForm to see the internal form of this list, which would involve RList:

One reason to use the head RList explicitly is when you want to treat some data as a list, which the automatic type detection of RLink would otherwise classify as a vector. For example, consider the following nested list:

It will be considered as a vector by default:

To force the list interpretation, you can use the following instead:

It is now interpreted as a list:

The same will also happen for a flattened list of data:

The confusion can only happen for lists representing regular arrays. Ragged lists are always interpreted as R lists:

You can always check yourself with FromRForm function: the call to ToRForm followed by the call to FromRForm should produce back the short form of your input:

As with RVector, you can send instances of RList directly to R:

You can always check what was sent to R by using REvaluate:

Also, as with RVector, the case when you assign some extra attributes is treated differently. Consider the following example:

The short (involving only lists) form of the Wolfram Language representation of your R object is no longer possible, since you have to store the attributes somewhere:

Note that the same ambiguity can happen here as well:

As you can see, lists were interpreted as vectors here. Here is the form that will force the list interpretation in this case:

Now the lists will be interpreted as R lists rather than R vectors:

Here is an example of a more complex list:

You can see that generally, it is a lot easier to work with the above short form than with a full internal form:

Either form can be sent to R:

You can check that they are the same in R:

Which, of course, means that they are the same when pulled back to the Wolfram Language:

This is a bit tangential to the present discussion, but there are two types of indexing possible for lists in R. Here is an example of the one with the same syntax as array indexing:

It provides an R list with a given element. The other one is the one with the double square bracket syntax, and it truly extracts the element:

This is reflected on the Wolfram Language side by the first result being wrapped in an extra List. This is also consistent with the conversion to the internal RLink form:

You should keep this difference in mind when working with R lists in RLink.

Wolfram Research (2012), RList, Wolfram Language function, https://reference.wolfram.com/language/RLink/ref/RList.html.


Wolfram Research (2012), RList, Wolfram Language function, https://reference.wolfram.com/language/RLink/ref/RList.html.


Wolfram Language. 2012. "RList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/RLink/ref/RList.html.


Wolfram Language. (2012). RList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/RLink/ref/RList.html


@misc{reference.wolfram_2023_rlist, author="Wolfram Research", title="{RList}", year="2012", howpublished="\url{https://reference.wolfram.com/language/RLink/ref/RList.html}", note=[Accessed: 13-April-2024 ]}


@online{reference.wolfram_2023_rlist, organization={Wolfram Research}, title={RList}, year={2012}, url={https://reference.wolfram.com/language/RLink/ref/RList.html}, note=[Accessed: 13-April-2024 ]}