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

Better error for replace_na #356

Closed
eibanez opened this Issue Aug 31, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@eibanez

eibanez commented Aug 31, 2017

It would be nice to improve the following error to say something like "b is not a valid column." Not a big deal, but it would be nice from a debugging perspective.

> library(tidyr)
> data = data_frame(a = c(1:3, NA))
> data2 <- data %>%
+   replace_na(list(a = 100, b = 0))
Error: `x` must be a vector

@hadley hadley added the bug label Nov 15, 2017

@hadley

This comment has been minimized.

Member

hadley commented Nov 16, 2017

Minimal reprex:

reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-15

library(tidyr)
df <- tibble::tibble(a = c(1, NA))
replace_na(df, list(a = 100, b = 0))
#> Error: `x` must be a vector

@hadley hadley closed this in 9737f5b Nov 16, 2017

@rlionheart92

This comment has been minimized.

rlionheart92 commented Apr 20, 2018

I suspect that this was closed as it is not possible? However, could the error message be changed to something more informative; along the lines of:
Error: All columns/vectors for replacement should be valid.
I had this error come up in some code I was modifying and it wasn't immediately obvious what was the issue,

@hadley

This comment has been minimized.

Member

hadley commented Apr 20, 2018

@rlionheart92 please open a new issue with reprex

@eibanez

This comment has been minimized.

eibanez commented Apr 20, 2018

I think this was fixed. The code above no longer errors and the function ignores replacement column names that are invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment