Description Usage Arguments Value Author(s) Examples
recode is a function recode a variable into recoded groups.
1 2 3 |
x |
is a vector which could be numeric, datetime or character |
groups |
is simlar with L in legal_set, but different in that for elements and substrs it should be a list |
Labels |
defines the labels for the returned value |
na.val |
label that are not included in the groups. |
method |
could be ranges, substrs and elements |
mode |
could be numeric, character or datetime |
tsFormat |
tsFormat to define the ts variable. |
a recoded vector
sontron
1 2 3 4 5 6 7 8 9 | x=rnorm(100)
recode(x,groups=c('(-Inf,0]','(0,Inf)'),Labels=c('negative_value','positive_value'),method='ranges',mode='numeric')
x=sample(letters[1:5],100,rep=T)
recode(x,groups=list(c('a','b'),c('c','d','e')),Labels=c('a-b','c-e'),method='elements',mode='character')
x=c('google','goodbye','doodle','doodoge','go!','bad')
recode(x,groups=list(c('goo'),c('doo')),Labels=c('include_goo','include_doo'),method='substrs',mode='character')
x=apply(expand.grid(2018,3:5,1:30),1,function(x)paste(x,collapse='-'))
recode(x,groups=c('[2018-3-1,2018-3-31]','[2018-4-1,2018-4-30]','[2018-5-1,2018-5-31]'),Labels=c('march','april','may'),method='ranges',mode='datetime',tsFormat='ymd')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.