getStructField | R Documentation |
These functions allow one to access a compiled/native struct object from within R based on the description of its fields. We can copy the entire structure or access individual fields using the two functions.
getStructField(ptr, id, type)
getStructValue(ptr,type)
ptr |
the reference to the native object. This should be an external pointer or coercable to one. |
id |
the name or index of the field of the structure to be accessed |
type |
the |
getStructValue
returns a list with the copies
of the values of the fields. If names are available from
the type
description, these are used as the names of the list.
getStructField
returns the individual R equivalent of the
current value of the corresponding field.
Duncan Temple Lang
structType
ptr = getNativeSymbolInfo("globalStruct")$address
myStruct.type = structType(list(s = sint16Type, i = sint32Type, d = doubleType, str = stringType))
getStructValue(ptr, myStruct.type)
getStructField(ptr, 2, myStruct.type)
getStructField(ptr, "i", myStruct.type)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.