Variable Labels

R's ability to handle variable labels is somewhat unsatisfying.

If you use the Hmisc package, you can take advantage of some labeling features.

library(Hmisc)
label(mydata$myvar) <- "Variable label for variable myvar"
describe(mydata)

Unfortunately the label is only in effect for functions provided by the Hmisc package, such as describe(). Your other option is to use the variable label as the variable name and then refer to the variable by position index.

names(mydata)[3] <- "This is the label for variable 3"
mydata[3] # list the variable