View source: R/explicit_guide.R
infer_guide | R Documentation |
Infers type of guide.
Default mapping function for explicit_guide.yamlet
where it replaces the key 'guide' with the return value.
infer_guide(x, data = NULL, default = "guide", token = "data", ...)
x |
character or list |
data |
atomic |
default |
value for unrecognized guides |
token |
character: discriptive term for 'data' used in warning |
... |
ignored |
* 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.
length-one character
Other explicit_guide:
explicit_guide.data.frame()
,
explicit_guide.dvec()
,
explicit_guide.yamlet()
,
explicit_guide()
,
implicit_guide.data.frame()
,
implicit_guide.dvec()
,
implicit_guide()
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.