ez.2label: e=e, f=f, g/h/i->i, j=j, k=k

View source: R/frame.R

ez.2labelR Documentation

e=e, f=f, g/h/i->i, j=j, k=k

Description

e=e, f=f, g/h/i->i, j=j, k=k

number ef[(0/1)]| attr number g(0/1) / factor attr number h[0/1]–>factor char i[girl/boy] |char jk[(girl/boy)]

Usage

ez.2label(
  x,
  col = NULL,
  add.non.labelled = TRUE,
  drop.missing.value = FALSE,
  prefix = FALSE,
  ...
)

Arguments

x

a data frame or a vector

col

internally evaluated by eval('dplyr::select()')
if x is a data frame, col is specified (e.g., "cond"), convert that col only
if x is a data frame, col is unspecified (i.e., NULL default), convert all possible cols in x
if x is not a data frame, col is ignored

add.non.labelled

logical, if TRUE, values without associated value label (ie, more values than "labels", hence not all values are labelled.) will also be converted to labels (as is). If FALSE, non-labelled values are converted to NA

drop.missing.value

(jerry: do not use) if TRUE, all types of missing value codes are converted (is_na attr) into NA before x is converted as factor. If FALSE, ignore is_na attr, missing values will be left as their original codes.

prefix

Logical, if TRUE, the value labels used as factor levels will be prefixed with their associated values.

Details

Variable label will be kept, but value labels will be removed to avoid confusion after converting to factor.
wrapper of sjmisc_to_label

Value

returns a factor with string as its levels or a data frame with changed col(s)

Note

See also ez.factorname

See Also

Other data transformation functions: ez.2char(), ez.2factor(), ez.2long(), ez.2lower(), ez.2value(), 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()

Examples

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

jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.