labeltable {vtable} | R Documentation |
Label Table Function
Description
This function output a descriptive table listing, for each value of a given variable, either the label of that value, or all values of another variable associated with that value. The table is output either to the console or as an HTML file that can be viewed continuously while working with data.
Usage
labeltable(
var,
...,
out = NA,
count = FALSE,
percent = FALSE,
file = NA,
desc = NA,
note = NA,
note.align = NA,
anchor = NA
)
Arguments
var |
A vector. Label table will show, for each of the values of this variable, its label (if labels can be found with |
... |
As described above. If specified, will show the values of these variables, instead of the labels of var, even if labels can be found. |
out |
Determines where the completed table is sent. Set to |
count |
Set to |
percent |
Set to |
file |
Saves the completed variable table file to HTML with this filepath. May be combined with any value of |
desc |
Description of variable (or labeling system) to be included with the table. |
note |
Table note to go after the last row of the table. |
note.align |
Set the alignment for the multi-column table note. Usually "l", but if you have a long note in LaTeX you might want to set it with "p" |
anchor |
Character variable to be used to set an anchor link in HTML tables, or a label tag in LaTeX. |
Details
Outputting the label table as a help file will make it easy to search through value labels, or to see the correspondence between the values of one variable and the values of another.
Labels that are not in the data will also be reported in the table.
Examples
if(interactive()){
#Input a single labelled variable to see a table relating values to labels.
#Values not present in the data will be included in the table but moved to the end.
library(sjlabelled)
data(efc)
labeltable(efc$e15relat)
#Include multiple variables to see, for each value of the first variable,
#each value of the others present in the data.
data(efc)
labeltable(efc$e15relat,efc$e16sex,efc$e42dep)
#Commonly, the multi-variable version might be used to recover the original
#values of encoded variables
data(USJudgeRatings)
USJudgeRatings$Judge <- row.names(USJudgeRatings)
USJudgeRatings$JudgeID <- as.numeric(as.factor(USJudgeRatings$Judge))
labeltable(USJudgeRatings$JudgeID,USJudgeRatings$Judge)
}