format_types_list: Format a list or character vector of types or error if...

Description Usage Arguments Details Value Examples

Description

A reference class must specify its fields, for example, c(data = "data.frame", ntrees = "integer"). These fields can be provided in several formats. The goal of this function is to ensure that format is correct, make small modifications if necessary, and error if there are problems.

Usage

1
format_types_list(props, what = "field")

Arguments

props

character or list. See full description of this function.

what

character. The name of the thing we are creating a types list for. The default is "field". This will be used to give more descriptive error messages.

Details

The following are valid formats for props:

If the provided props does not satisfy any of these, an error will be invoked.

# TODO: (RK) Figure out what inferring means...

Value

a list that is guaranteed to have distinct non-zero length names and values that are of type character of length 1.

Examples

1
2
3
4
5
6
stopifnot(identical(format_types_list(c(a = 'character', b = 'data.frame')),
  list(a = 'character', b = 'data.frame')))
stopifnot(identical(format_types_list(c('a', 'b')), list(a = 'ANY', b = 'ANY')))
stopifnot(identical(format_types_list(list(a = 'character')), list(a = 'character')))
# The following will error because of duplicate names:
# format_types_list(list(a = 'character', a = 'character'))

robertzk/refclass documentation built on May 27, 2019, 10:36 a.m.