I have a bunch of Stata .dta files that I would like to use in R.
My problem is that the variable names are not helpful to me as they are like \"q0100,\" \"q0565,\"
When using the haven package:
if the data set you are importing is heavy, viewing the data in Rstudio might not be optimal.
You can instead get a data.frame with column names, column labels and an indicator for whether the column is labelled:
d <- read_dta("your_stata_data.dta")
vars <- data.frame(
"name" = names(d),
"label" = sapply(d, function(x) attr(x, "label")) %>% as.character(),
"labelled" = sapply(d, is.labelled) )
Note: need to use as.characted in order to avoid NULL in the labels being dropped and therefore ending up with different vector lengths.