Skip to content

haven::labelled() clashes on dplyr::if_else() with numeric #765

@skolenik

Description

@skolenik

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.

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)))
> packageVersion("haven")
[1] ‘2.5.4’
> packageVersion("vctrs")
[1] ‘0.6.5’

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    reprexneeds a minimal reproducible example

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions