# sample data set, imported from SPSS. Variable labels are attached
# as attribute to the data frame (so variables currently don't have this attribute)
data(efc)
# get variable labels
variable.labels <- get_var_labels(efc)
# set variable labels as attribute to each single variable of data frame
efc <- set_var_labels(efc, variable.labels)
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.
sjp.frq(dummy, title = NULL)
Run the code above in your browser using DataLab