Standard R does not provide for variable labels, but lessR
does. Read the labels Read
function and setting labels=TRUE
. This setting can be accomplished with the short name for the Read
function, rd
.Each row of the file that contains the labels, including the first row, consists of the variable name, a comma, and then the label, that is, standard csv
format such as obtained with the csv
option from a standard worksheet application such as Microsoft Excel or LibreOffice Calc. Not all variables in the data frame that contains the data, mydata
by default, need have a label, and the variables with their corresponding labels can be listed in any order. Here is an example of this file for the dat.employee
data file included in this lessR
package.
Years,"Years Employed in the Company"
Gender,"Male or Female"
Dept,"Department Employed"
Salary,"Annual Salary (USD)"
Satisfaction,"Satisfaction with Work Environment"
HealthPlan,"1=GoodHealth, 2=YellowCross, 3=BestCare"
Not all variables need have a label, and the variables with their corresponding labels can be listed in any order.
The label
function is automatically accessed by the lessR
functions that provide data analysis, such as automatically providing the title of a graph as the corresponding variable label. This function can also be added to standard R function calls as well, such as an argument for main
in graphics output, where main
is the title of the graph.