setAltClass: Define an altWrapper class

Description Usage Arguments Value Examples

View source: R/altWrapper-main.R

Description

Define an altWrapper class by specifying its name and data type

Usage

1
2
setAltClass(className, classType = c("raw", "logical", "integer",
  "double"))

Arguments

className

Character, the name of the class

classType

Character, the type of the altWrapper

Value

No return value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Define the ALTREP functions
length_func <- function(x) length(x)
get_ptr_func <- function(x,writeable) x


## Define the altWrapper class and its functions
setAltClass(className = "example", classType = "integer")
setAltMethod(className = "example", getLength = length_func)
setAltMethod(className = "example", getDataptr = get_ptr_func)

## Create an altWrapper object by providing the class name and data.
A <- newAltrep(className = "example", x = 1L:10L)
A

Jiefei-Wang/AltWrapper documentation built on Oct. 30, 2019, 7:43 p.m.