# \dontshow{
#These tests use the out='htmlreturn' option
#so that the same process of generating HTML is followed
#but a browser window is not opened during testing.
#This process is identical to regular operation except that
#HTML is written to the R output rather than a browser.
#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,out='htmlreturn')
#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,out='htmlreturn')
#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,out='htmlreturn')
# }
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)
}
Run the code above in your browser using DataLab