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

remove_labels does not work with tibbles #28

Closed
lefkiospaikousis opened this issue Oct 23, 2019 · 1 comment
Closed

remove_labels does not work with tibbles #28

lefkiospaikousis opened this issue Oct 23, 2019 · 1 comment

Comments

@lefkiospaikousis
Copy link

@lefkiospaikousis lefkiospaikousis commented Oct 23, 2019

Hi! Thanks for your package. I 've been using it a lot and it significantly improves my workflow

I (accidentally) stumbled upon this small issue and thought I would I'd let you know

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

mtcars_df <- 
  mtcars %>% 
    dplyr::select(mpg:disp) %>% 
    sjlabelled::set_label(
      c("mileage", "cylinder","display")
    ) 

mtcars_tb <- 
  mtcars %>% 
    tibble::as_tibble() %>% 
    dplyr::select(mpg:disp) %>% 
    sjlabelled::set_label(
      c("mileage", "cylinder","display")
    ) 

dplyr::lst(mtcars_df, mtcars_tb) %>% purrr::map(~ class(.))
#> $mtcars_df
#> [1] "data.frame"
#> 
#> $mtcars_tb
#> [1] "tbl_df"     "tbl"        "data.frame"

mtcars_df %>% purrr::map(~ attributes(.))
#> $mpg
#> $mpg$label
#>       mpg 
#> "mileage" 
#> 
#> 
#> $cyl
#> $cyl$label
#>        cyl 
#> "cylinder" 
#> 
#> 
#> $disp
#> $disp$label
#>      disp 
#> "display"
mtcars_tb %>% purrr::map(~ attributes(.))
#> $mpg
#> $mpg$label
#>       mpg 
#> "mileage" 
#> 
#> 
#> $cyl
#> $cyl$label
#>        cyl 
#> "cylinder" 
#> 
#> 
#> $disp
#> $disp$label
#>      disp 
#> "display"

# REMOVE THE LABELS information and CHECK

mtcars_df %>% 
  finalfit::remove_labels() %>% 
  purrr::map(~ attributes(.))
#> $mpg
#> NULL
#> 
#> $cyl
#> NULL
#> 
#> $disp
#> NULL

mtcars_tb %>% 
  finalfit::remove_labels() %>% 
  purrr::map(~ attributes(.))
#> $mpg
#> $mpg$label
#>       mpg 
#> "mileage" 
#> 
#> 
#> $cyl
#> $cyl$label
#>        cyl 
#> "cylinder" 
#> 
#> 
#> $disp
#> $disp$label
#>      disp 
#> "display"

Created on 2019-10-23 by the reprex package (v0.3.0)

ewenharrison added a commit that referenced this issue Oct 24, 2019
@ewenharrison
Copy link
Owner

@ewenharrison ewenharrison commented Oct 24, 2019

Thanks. This is now fixed in the github version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants