ExternalArray-class | R Documentation |
These classes and methods provide the foundation for working with native arrays in C/C++ code as if they were vectors, matrices and arrays in R. The idea is that we have the address of or a reference to the native object and we have information about the dimensions of that object. We then create an R object that has that information and with this, we can access individual elements or collections of elements, and assign values from R to elements of the native array.
Instances of these classes can be used without knowing the dimensions of the native arrays. In this case, the R programmer/user has to ensure that the indices are appropriate. Errors in this can cause R to crash.
Objects can be created by calls of the form new("ExternalArray", ...)
.
Typically, such objects will be created in programmatically generated
code that provides an interface between R and existing native C/C++
code.
Sometimes, we will have an external pointer object in R
that we know refers to a native array and then we can
create an instance of ExternalArray
in R using that reference.
But this is less robust as the user must ensure that the dimensions are
correct. This should be computed from the native code.
elementSize
:Object of class "integer"
the size
of each element in bytes
ref
:Object of class "externalptr"
the address
of the native object
classes
:Object of class "character"
a
collection of class names for this object, typically corresponding
to the native type.
Class "RC++Reference"
, directly.
No methods defined with class "ExternalArray" in the signature.
Duncan Temple Lang
showClass("ExternalArray")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.