Closed
Description
openedon Sep 24, 2021
I am trying to export a data set as an sav file via write_sav
. It would be convenient for me to have haven_labelled versions of variables as well as pure factor variables. I'm trying to export the data with the labelled versions of the variables with lower case names and with the factor version of the variables
#This creates my data frame with one labelled variable and a duplicate factor
test<-structure(list(francophone = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), labels = c(Francophone = 1, `Not Francophone` = 0), label = "Dichotomous variable, R is francophone", class = c("haven_labelled", "vctrs_vctr", "double")), Francophone = structure(c(1L, 1L, 1L,1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Not Francophone", "Francophone"), label = "Dichotomous variable, R is francophone", class = "factor")), row.names = c(NA,-10L), class = c("tbl_df", "tbl", "data.frame"))
#Create a second factor but with a significantly different name
test$Franco<-test$Francophone
#Export the data-set and look.
test %>%
write_sav(., path="~/Desktop/test2.sav")
My desired outcome would be for write_sav()
to treat variable names case sensitively
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment