inst/doc/labelleddata.R

## ----echo = FALSE-------------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## -----------------------------------------------------------------------------
factor(c("low", "high", "mid", "high", "low"))

## -----------------------------------------------------------------------------
library(sjlabelled)
data(efc)
str(efc$e42dep)

## ----warning=FALSE, fig.height=6, fig.width=7---------------------------------
library(sjlabelled)
data(efc)
barplot(
  table(efc$e42dep, efc$e16sex), 
  beside = TRUE, 
  legend.text = TRUE
)

## ----warning=FALSE, fig.height=6, fig.width=7---------------------------------
barplot(
  table(sjlabelled::as_label(efc$e42dep),
        sjlabelled::as_label(efc$e16sex)), 
  beside = TRUE, 
  legend.text = TRUE
)

## ----warning=FALSE, fig.height=6, fig.width=7---------------------------------
barplot(
  table(sjlabelled::as_label(efc$e42dep),
        sjlabelled::as_label(efc$e16sex)), 
  beside = TRUE, 
  legend.text = TRUE,
  main = get_label(efc$e42dep)
)

## -----------------------------------------------------------------------------
efc.sub <- subset(efc, subset = e16sex == 1, select = c(4:8))
str(efc.sub)

## ---- message=FALSE-----------------------------------------------------------
efc.sub <- copy_labels(efc.sub, efc)
str(efc.sub)

Try the sjlabelled package in your browser

Any scripts or data that you put into this service are public.

sjlabelled documentation built on April 10, 2022, 5:05 p.m.