Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind_rows of data frames with haven_labelled variables fails #758

Open
sjkiss opened this issue Jun 19, 2024 · 3 comments
Open

bind_rows of data frames with haven_labelled variables fails #758

sjkiss opened this issue Jun 19, 2024 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@sjkiss
Copy link

sjkiss commented Jun 19, 2024

I have a package that stores a number of survey datasets with recoded data in them. The script below installs the package and tries to construct a tabular dataset from the various datasets. It was working for me up until recently. However, now it returns an error

Error in bind_rows(): ! Can't combine ..1$male<haven_labelled> and..2$male<haven_labelled>. ✖ Some attributes are incompatible. ℹ The author of the class should implement vctrs methods.

This is a stripped down version of the code and it reproduces the error.

It was working for me earlier.

library(tidyverse)
remotes::install_github("sjkiss/cesdata2")
#> Using GitHub PAT from the git credential store.
#> Skipping install of 'cesdata2' from a github remote, the SHA1 (4bf65d7e) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(cesdata2)
# List data frames
ces.list<-list(ces84, ces88, ces93, ces97, ces00, ces15phone, ces15web, ces19phone, ces19web, ces21)
#Provide names for list
names(ces.list)<-c( 1984, 1988, 1993, 1997, 2000, "2015 Phone", "2015 Web","2019 Phone", "2019 Web", 2021)
#Common variables to be selected

common_vars<-c('male',
               'sector', 
               'occupation', 'vote')

ces.list %>% 
  map(., select, any_of(common_vars))%>%
  #bind_rows smushes all the data frames together, and creates a variable called election
  bind_rows()->ces
#> Error in `bind_rows()`:
#> ! Can't combine `..1$male` <haven_labelled> and `..2$male` <haven_labelled>.
#> ✖ Some attributes are incompatible.
#> ℹ The author of the class should implement vctrs methods.
#> ℹ See <https://vctrs.r-lib.org/reference/faq-error-incompatible-attributes.html>.

Created on 2024-06-19 with reprex v2.1.0

@sjkiss
Copy link
Author

sjkiss commented Jun 19, 2024

Reverting to haven package 2.3.1 works. Note the potential similarity with this issue

@sjkiss
Copy link
Author

sjkiss commented Jun 19, 2024

Correction: It does not. I don't understand what is going on.

@gorcha gorcha added the bug an unexpected problem or unintended behavior label Jun 28, 2024
@gorcha
Copy link
Member

gorcha commented Jun 28, 2024

Hi @sjkiss, I suspect this is a change in the vctrs package - could you please let me know what version of vctrs you have installed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants