In SPSS there appears to be the column name and then the column "label" which is like a description of the column. If I load an SPSS file into R via haven and a look at the file with the "View" function, I can see the column label written under the column name in that "View" window. So it's there somewhere, but if I look at the tables attributes, I can't find it. It's been kinda hard to search for answers because it seems like SPSS's equivalent of factors are also called labels so most topics are about that. Have has a bunch of label functions, but they're all about the factor labels and not the column name labels. I really just want to access the column labels in R and update them.
Asked
Active
Viewed 159 times
0
-
This might help: https://www.r-bloggers.com/2015/03/getting-variable-labels-in-r-from-spss/ – Pawel Kranzberg Oct 16 '20 at 19:08
-
The attribute doesn't exists in the haven version of the tibble. I can't seem to download foreign via CRAN in whatever version of R I have either. – James B Oct 16 '20 at 19:15
-
2Have a look at the `labelled` package on which `haven` is built, e.g. `labelled::var_label(iris$Sepal.Length) <- "Length of the sepal"` will change the variable or column label, while `labelled::var_label(iris$Sepal.Length)` will print the label. – stefan Oct 16 '20 at 19:28
-
Thanks that looks helpful. I had gotten attr(x$columnname, "label") to work, but who knows if I'll remember that exact formation in the future. – James B Oct 16 '20 at 19:35