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

More descriptive error message needed if column names are NA #1101

Closed
holgerbrandl opened this issue Apr 24, 2015 · 5 comments
Closed

More descriptive error message needed if column names are NA #1101

holgerbrandl opened this issue Apr 24, 2015 · 5 comments
Assignees
Milestone

Comments

@holgerbrandl
Copy link

@holgerbrandl holgerbrandl commented Apr 24, 2015

names(iris)[1] <- NA
iris %>% filter(Species=="setosa")
iris %>% arrange(Species)

Both calls give

Error in if (any(names2(x) == "")) { 
missing value where TRUE/FALSE needed

and it is not clear that the problem is a column which is not used at all in the method call. It should rather say something like
"Error: Column(s) with missing name(s) in input table. To use dplyr all columns are required to have a name."

The problem seems related to tidyverse/tidyr#68

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Apr 24, 2015

And the error leads directly to as_data_frame:

> traceback()
15: as_data_frame(data) at tbl-df.r#71
14: tbl_df(.data) at manip.r#24
13: filter_(tbl_df(.data), .dots = dots)
12: as.data.frame(filter_(tbl_df(.data), .dots = dots)) at dataframe.R#198
11: filter_.data.frame(.data, .dots = lazyeval::lazy_dots(...)) at manip.r#24
10: filter_(.data, .dots = lazyeval::lazy_dots(...)) at manip.r#18
9: filter(., Species == "setosa")
8: function_list[[k]](value)
7: withVisible(function_list[[k]](value))
6: freduce(value, `_function_list`)
5: `_fseq`(`_lhs`)
4: eval(expr, envir, enclos)
3: eval(quote(`_fseq`(`_lhs`)), env, env)
2: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
1: iris %>% filter(Species == "setosa")
> iris %>% filter(Species=="setosa") %>% str
Error in if (any(names2(x) == "")) { :
  valeur manquante là où TRUE / FALSE est requis
>
> as_data_frame(iris)
Error in if (any(names2(x) == "")) { :
  valeur manquante là où TRUE / FALSE est requis

@hadley hadley added this to the 0.5 milestone May 19, 2015
@romainfrancois romainfrancois self-assigned this Jul 16, 2015
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jul 16, 2015

Now getting this:

> names(iris)[1] <- NA
> iris %>% filter(Species=="setosa")
Error: All elements must be named
> iris %>% arrange(Species)
Error: All elements must be named

@holgerbrandl does that work for you.

@holgerbrandl
Copy link
Author

@holgerbrandl holgerbrandl commented Jul 16, 2015

Much better, although I personally find "elements" rather unspecific. Why not "columns"?

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jul 16, 2015

Sure. Would you send us a pull request that @hadley can have a look at.

@holgerbrandl
Copy link
Author

@holgerbrandl holgerbrandl commented Jul 16, 2015

done with #1271

krlmlr pushed a commit to krlmlr/dplyr that referenced this issue Mar 2, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants