My dataframe (df) with column names "8A_1" and 8A_2" is:
8A_1 8A_2
1 2 2
2 4 3
3 4 4
4 4 3
5 4 3
6 1 4
7 2 4
8 2 4
9 4 3
10 4 4
The variable labels are (which are added to the variables with the help of the Hmisc package)
var.labels =
c("8A_1"="Variable 1",
"8A_2" = "Variable 2")
library(Hmisc)
label(df) = lapply(names(var.labels),
function(x) label(df[,x]) = var.labels[x])
var.labels
8A_1 8A_2 "Variable 1" "Variable 2"
plot (df$"8A_1", df$"8A_2")
The above command marks df$"8A_1" and df$"8A_2" in the axes. It does not the variable labels that I want. How can I get variable labels instead of variable names in plots or in other statistical analysis (as it is done for example in SPSS)?