# sample data set, imported from SPSS.
data(efc)
library(sjPlot)
sjt.frq(efc$e42dep)
sjt.frq(data.frame(efc$e42dep, efc$e16sex))
# ---------------------------------------------
# manually set value and variable labels
# ---------------------------------------------
dummy <- sample(1:4, 40, replace=TRUE)
dummy <- set_val_labels(dummy, c("very low", "low", "mid", "hi"))
dummy <- set_var_labels(dummy, "Dummy-variable")
# auto-detection of value labels by default, auto-detection of
# variable labels if parameter "title" set to NULL.
library(sjPlot)
sjp.frq(dummy, title = NULL)
# ---------------------------------------------
# Set variable labels for data frame
# ---------------------------------------------
dummy <- data.frame(a = sample(1:4, 10, replace = TRUE),
b = sample(1:4, 10, replace = TRUE),
c = sample(1:4, 10, replace = TRUE))
dummy <- set_var_labels(dummy,
c("Variable A",
"Variable B",
"Variable C"))
str(dummy)
# remove one variable label
dummy <- set_var_labels(dummy,
c("Variable A",
"",
"Variable C"))
str(dummy)
Run the code above in your browser using DataLab