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

complete(fill) should accept single value #1351

Closed
hadley opened this issue Apr 13, 2022 · 2 comments
Closed

complete(fill) should accept single value #1351

hadley opened this issue Apr 13, 2022 · 2 comments

Comments

@hadley
Copy link
Member

hadley commented Apr 13, 2022

library(tidyr)

df <- tibble(x = c(1, NA), y = c(1, NA))
df |> complete(fill = 0)
#> Error in `replace_na()`:
#> ! `replace` must be a list.

Created on 2022-04-13 by the reprex package (v2.0.1)

This would make it consistent with pivot_wider(values_fill) and friends.

@DavisVaughan
Copy link
Member

DavisVaughan commented Apr 13, 2022

We seem to go back and forth on how we feel about this 😄 #1108 (comment) and #1108 (comment)

Implementing this would mean that every column in df would have to be the same type (because the 1 replace value would be applied to every column), which seems extremely unlikely for the typical analysis.

It would also make code harder to read. i.e. is replace_na(x, 1) replacing values in a vector x or a data frame x?

@hadley
Copy link
Member Author

hadley commented Apr 13, 2022

Oh yeah, you'll probably need to remind me about this again in a couple of years 😄

@hadley hadley closed this as completed Apr 13, 2022
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