infer_guide: Infer Type of Guide

View source: R/explicit_guide.R

infer_guideR Documentation

Infer Type of Guide

Description

Infers type of guide. Default mapping function for explicit_guide.yamlet where it replaces the key 'guide' with the return value.

Usage

infer_guide(x, data = NULL, default = "guide", token = "data", ...)

Arguments

x

character or list

data

atomic

default

value for unrecognized guides

token

character: discriptive term for 'data' used in warning

...

ignored

Details

* If x is a list, the result is 'codelist'.

* If x otherwise has length greater than 1, result is the default value.

* If x is_parseable, result is 'units'. Use install_unit to register a non-default unit.

* If x contains two or more percent signs, result is 'format' (i.e. a 'format' string for a date or time class).

* If x is (encoded), result is 'encoding'.

* A length-one value of x not otherwise recognized is assumed to be an attempt to provide a length-one 'codelist'.

If data is supplied (not NULL), a warning is issued for a codelist with elements not present.

Value

length-one character

See Also

Other explicit_guide: explicit_guide.data.frame(), explicit_guide.dvec(), explicit_guide.yamlet(), explicit_guide(), implicit_guide.data.frame(), implicit_guide.dvec(), implicit_guide()

Examples

infer_guide('a') # recognized unit
infer_guide('z') # unrecognized as unit, evaluates to guide
## Not run: 
# evaluates to codelist but data suggests otherwise (warning)
infer_guide(as.list(letters), data = LETTERS)

## End(Not run)
infer_guide(c(1,2,3))                   # guide
infer_guide(list('a','b','c'))          # codelist
infer_guide(list(a = 1, b = 2, c = 3))  # codelist
infer_guide(list(a = 1))                # codelist
infer_guide('kg/m^2')                   # units
infer_guide('%')                        # units
infer_guide('%Y-%m-%d')                 # format
infer_guide('//a/1//b/2//c/3//')        # encoding


bergsmat/yamlet documentation built on Feb. 18, 2024, 5:50 a.m.