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)āļāļąāļāđāļāļĨāļ·āđāļāļāđāļāļĒ
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āļāļąāļāđāļāļĨāļ·āđāļāļāđāļāļĒ
names(mydata)[3] <- "This is the label for variable 3" mydata[3] # list the variable
Want to practice more? Try this exercise on variable recoding from DataCamp
āđāļāļāļŠāļēāļĢ
R's ability to handle variable labels is somewhat unsatisfying.
If you use the Hmisc package, you can take advantage of some labeling features.
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.
To Practice
Want to practice more? Try this exercise on variable recoding from DataCamp