hlist_class: Create a subclass of 'HList'

Description Usage Arguments Value See Also Examples

Description

Create a subclass of HList, which restricts elements of the list to be a specified class.

Usage

1
2
  hlist_class(Class, classtype = "ANY", empty_names = TRUE,
    unique_names = FALSE, where = topenv(parent.frame()))

Arguments

Class

character string name of the new class that will extend HList.

classtype

character The name of the class which all elements must inherit from.

empty_names

logical If FALSE, then no names can have values "" or NA.

unique_names

logical If TRUE, then names must be unique.

where

Passed to setClass. The environment in which to store the definition.

Value

function with usage function(...), which will create objects of the newly defined class.

See Also

"FunctionList" for a subclass created with this function used in this section. HList.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
NumericList <-
  hlist_class("NumericList", "numeric")
# creates a new class "NumericList"
showClass("NumericList")
# Create a new object of class NumericList
foo <- NumericList(a=1, b=2)
print(foo)
foo[["c"]] <- 3
print(foo)
# error
try(foo[["c"]] <- 3)

jrnold/r-checker documentation built on May 20, 2019, 1:04 a.m.