-
Notifications
You must be signed in to change notification settings - Fork 117
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
haven::labelled() clashes on dplyr::if_else() with numeric #765
Comments
I'm not able to reproduce this error. library(haven)
#> Warning: package 'haven' was built under R version 4.4.2 mtcars |> tibble::as_tibble() |>
dplyr::mutate(this=haven::labelled(haven::tagged_na("a"), labels=c("A" = haven::tagged_na("a")))) |>
dplyr::mutate(this=dplyr::if_else(am==1, this, as.numeric(NA)))
#> # A tibble: 32 × 12
#> mpg cyl disp hp drat wt qsec vs am gear carb this
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl+lbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 NA(a) [A]
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 NA(a) [A]
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 NA(a) [A]
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 NA
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 NA
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 NA
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 NA
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 NA
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 NA
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 NA
#> # ℹ 22 more rows Created on 2024-12-11 with reprex v2.1.0 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.4.1 (2024-06-14 ucrt)
#> os Windows 10 x64 (build 19045)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.utf8
#> ctype English_United States.utf8
#> tz America/New_York
#> date 2024-12-11
#> pandoc 3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.1)
#> crayon 1.5.3 2024-06-20 [1] CRAN (R 4.4.1)
#> digest 0.6.36 2024-06-23 [1] CRAN (R 4.4.1)
#> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.4.1)
#> evaluate 0.24.0 2024-06-10 [1] CRAN (R 4.4.1)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.1)
#> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.1)
#> forcats 1.0.0 2023-01-29 [1] CRAN (R 4.4.1)
#> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.1)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.1)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.4.1)
#> haven * 2.5.4 2023-11-30 [1] CRAN (R 4.4.2)
#> hms 1.1.3 2023-03-21 [1] CRAN (R 4.4.1)
#> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
#> knitr 1.47 2024-05-29 [1] CRAN (R 4.4.1)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.1)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.1)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.1)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.1)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.4.1)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.4.1)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.4.0)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.4.0)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.4.1)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.1)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.4.1)
#> rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.1)
#> rmarkdown 2.27 2024-05-17 [1] CRAN (R 4.4.1)
#> rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.4.1)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.1)
#> styler 1.10.3 2024-04-07 [1] CRAN (R 4.4.1)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.4.1)
#> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.1)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.1)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.1)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.4.1)
#> xfun 0.45 2024-06-16 [1] CRAN (R 4.4.1)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.4.0)
#>
#> [1] C:/Program Files/R/R-4.4.1/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some code that deals with labeled
tagged_na()
, and on some occasions this class does not want to play with something as simple as<dbl>
, see the screenshot.The closest I can get to reprex is below although it does not really produce the error I am seeing.
The text was updated successfully, but these errors were encountered: