ez.2value | R Documentation |
e=e, f(0,1)<-f[1,2], g<-g/h/i/j/k
number e<-f[(0/1)]| attr number g(0/1)<–factor attr number h[0/1] / factor char i[girl/boy] / char j/k[(girl/boy)]
ez.2value(x, col = NULL, start.at = 0, keep.labels = TRUE, ...)
x |
a data frame or a vector/col |
col |
internally evaluated by eval('dplyr::select()')
|
start.at |
starting index, i.e. the lowest numeric value of the variable's value range.
|
Variable label will be kept. opposite of ez.2factor
, ez.2label
wrapper of sjmisc_to_value
returns a numeric variable or a data frame with changed col(s)
if x is a factor with normal chars, will be converted to 1 2 3 etc, see the example
if x, however, is a factor with chars of numbers ez.2value(c("2","4","6.3"),start.at=NULL), will be converted to (2 4 6.3) etc, see the example
ez.num
Other data transformation functions:
ez.2char()
,
ez.2factor()
,
ez.2label()
,
ez.2long()
,
ez.2lower()
,
ez.2wide()
,
ez.compute()
,
ez.del()
,
ez.label.get()
,
ez.label.set()
,
ez.labels.get()
,
ez.labels.set()
,
ez.move()
,
ez.newcol()
,
ez.num()
,
ez.recode()
,
ez.recols()
,
ez.recol()
,
ez.rename()
,
ez.replace()
,
ez.rncols()
,
ez.rncol()
,
ez.select()
,
ez.sort()
,
ez.split()
,
ez.str()
,
ez.unique()
,
left_join()
e=c(1,2); f=factor(1:2)
g=c(0,0,1,1,1,0); attr(g,'value.labels') <- c(boy=1,girl=0)
h=factor(c(0,0,1,1,1,0)); attr(h,'labels') <- c(boy=1,girl=0)
i=factor(c('girl','girl','boy','boy','boy','girl'))
j=c('x','y'); k=factor(c('x','y'))
ez.2label: e=e, f=f, g/h/i->i, j=j, k=k
ez.2value: e=e, f(0,1)<-f[1,2], g<-g/h/i/j/k
ez.2factor: ef->f, g/h->h, i=i, factor[x,y,z]<j/k
ez.2value(c('','2','1'),start.at = NULL) # -> c(1,3,2)
ez.2value(c('','2','1'),start.at = 0) # -> c(0,2,1)
ez.num(c('','2','1')) # -> c(NA,2,1)
ez.2value(c("2","4","6.3"),start.at=NULL) # -> (2.0 4.0 6.3)
ez.2value(factor(c("2","4","7.3")),start.at=0) # -> (0.0 2.0 5.3)
for consistent and easy convertion, consider to use ez.num(c("2","4","7.3")), ez.num(factor(c("2","4","7.3")), force=T) in this case
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.