Skip to content

write_sav() does not check for duplicated variable names #641

Closed

Description

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")

Screen Shot 2021-09-24 at 10 32 30 AM

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

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions