| codify.default | R Documentation |
Reduces x integer codes with appropriate decorations.
Result is like as.integer(as.numeric(x)) + offset
but has a guide attribute: a list of integers
whose names are the original levels of x.
A wrapper for as.integer(classified(x).
## Default S3 method:
codify(
x,
offset = 0L,
...,
persistence = getOption("yamlet_persistence", TRUE)
)
x |
anything for which there is a 'classified' method; see |
offset |
an integer value to add to intermediate result |
... |
passed to |
persistence |
whether to return 'dvec' (is.integer(): TRUE) or just integer. |
integer (possibly of class dvec)
as.integer.classified mimic
Other classified:
[.classified(),
[<-.classified(),
[[.classified(),
[[<-.classified(),
as.integer.classified(),
c.classified(),
classified(),
classified.classified(),
classified.data.frame(),
classified.default(),
classified.dvec(),
classified.factor(),
desolve.classified(),
unclassified(),
unclassified.classified(),
unclassified.data.frame()
library(magrittr)
# convert to decorated integer
c('knife','fork','spoon') %>% codify
# implement offset
c('knife','fork','spoon') %>% codify(-1)
# globally defeat the 'persistence' paradigm
options(yamlet_persistence = FALSE)
c('knife','fork','spoon') %>%
codify %>%
class # integer
# remove option to restore default persistence paradigm
options(yamlet_persistence = NULL)
c('knife','fork','spoon') %>%
codify %>%
class # dvec
# locally defeat persistence paradigm
c('knife','fork','spoon') %>%
codify(persistence = FALSE) %>%
class # integer
# pass levels
c('knife','fork','spoon') %>%
codify(levels = c('spoon', 'knife', 'fork'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.