newAltrep: Make an altWrapper object

Description Usage Arguments Value Examples

View source: R/altWrapper-main.R

Description

This function make an altWrapper object from an altWrapper class specified by the class name. The altWrapper class can be set via setAltClass and setAltMethod functions.

Usage

1
2

Arguments

className

Character, the name of an altWrapper class

x

The data of the returned altWrapper object

attributes

Named list, attributes that will be attached to the object. The attribute class will be ignored

S3Class

Logical or character vector, whether the return value is of an altWrapper S3 class. If the argument is a character vector, it will overwrite the default settings and resulting in an S3 object with the class type specified in the character vector.

S4Class

Logical or character, whether the return value is of an AltWrapper S4 class. If the argument is a character, it must be a class name and the return value is an S4 object specified by the class name. An error will be returned if both S3Class and S4Class are defined.

Value

An ALTREP vector

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.