RLink`
RLink`

RDataTypeRegister

RDataTypeRegister[type,fwpatt,fwrule,bckpatt,bckrule] registers a new Wolfram Language representation for a data type with name type.

Details and Options

  • The type argument should normally be a string.
  • Expressions matching the fwpatt pattern will be considered by RLink to be of type type.
  • The rule fwrule instructs RLink how to convert the new Wolfram Language representation to representation based on RObject.
  • The bckpatt pattern identifies types of expressions based on RObject that RLink considers to represent objects of type type.
  • The rule bckrule instructs RLink how to convert such expressions to a more convenient, higher-level Wolfram Language representation defined with RDataTypeRegister.
  • If the type with the name type has already been registered, RDataTypeRegister returns $Failed.

Examples

Basic Examples  (1)

First load and install the R runtime:

This will register a very simple data type (wrapper) that wraps around some core R data type, such as a vector:

You can test that the definition is now effective by using ToRForm:

You can now send your data to R, using the custom data container just defined:

The result is automatically converted according to the inverse conversion rule used above in RDataTypeRegister, when returned back from R:

You can see that this will also work on derivative R objects obtained through manipulations with the original object that do not change its type (class in R):

You can now unregister the data type:

Now the following will get back the usual representation based on RObject:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_rdatatyperegister, organization={Wolfram Research}, title={RDataTypeRegister}, year={2012}, url={https://reference.wolfram.com/language/RLink/ref/RDataTypeRegister.html}, note=[Accessed: 18-November-2024 ]}