value
option and assign the output to a specified data frame.VariableLabels(x, value=NULL, data=mydata, quiet=getOption("quiet"))
NULL
.TRUE
, no text output. Can change system
default with theme
function.lessR
does. Read the labels by specifying a file reference as the first argument of the function call, or read the labels with the lessR
Read
function, as explained in the corresponding documentation. Individual variable labels can also be assigned with this function. Not all variables need have a label, and the variables with their corresponding labels can be listed or assigned in any order. When all or some of the labels are read, either from the console or an external csv
or Excel
file, each line of the file contains the variable name and then the associated variable label. The file types of .csv
and .xlsx
in the file reference listed in the first position of the function call are what trigger the interpretation of the argument as a file reference.Read
.# read the internal lessR data frame that contains variable labels
mydata <- Read("Employee", format="lessR")
# processing with a standard R transformation removes the labels
mydata <- transform(mydata, Years = Years)
# show that the labels are now gone
details.brief()
# construct and read variable labels from console
lbl <- "
Years,time of company employment
Gender,Male or Female
Dept,department employed
Salary,annual salary
Satisfaction,satisfaction with work environment
HealthPlan,1=GoodHealth 2=YellowCross 3=BestCare
"
mydata <- VariableLabels(lbl)
# read variable labels from a csv file
mydata <- Read("Employee", format="lessR")
mydata <- transform(mydata, Years = Years) # remove the labels
# mydata <- VariableLabels("http://lessRstats.com/data/employee_lbl.csv")
# add/modify a single variable label
mydata <- VariableLabels(Salary, "bucks buck")
details.brief()
# list the contents of a single variable label
VariableLabels(Salary)
# display all variable labels
VariableLabels()
Run the code above in your browser using DataLab