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

cryptic error messages when col_select has no valid columns #521

Open
khusmann opened this issue Nov 12, 2023 · 1 comment
Open

cryptic error messages when col_select has no valid columns #521

khusmann opened this issue Nov 12, 2023 · 1 comment

Comments

@khusmann
Copy link

Hello! Was getting this cryptic error message in readr::read_delim and traced it to vroom. It occurs when col_select has no valid columns. MWE:

foo <- "a,b,c\n1,2,3\n"
vroom(I(foo), delim=",", col_select=c(d))

# Output:
# Error in UseMethod("collector_value") :                                                                                                                 
#  no applicable method for 'collector_value' applied to an object of class "c('collector_skip', 'collector')"

vroom(I(foo), delim=",", col_select=c(d, e, f))

# Output:
# Error in UseMethod("collector_value") :                                                                                                                 
#  no applicable method for 'collector_value' applied to an object of class "c('collector_skip', 'collector')"

Interestingly, if you read at least one valid column, you get a much nicer error:

vroom(I(foo), delim=",", col_select=c(a, d))
# Output:
# Error in `vroom_select()`:                                                                                                                              
# ! Can't subset columns that don't exist.
# ✖ Column `d` doesn't exist.

I tested on both vroom v 1.6.1 and 1.6.4 and got the same behavior.

Seems related to this issue reported in readr, but not quite. Empty selections using all_of() (as reported there) give nice errors as expected, so this appears to be a separate thing:

vroom(I(foo), delim=",", col_select=c(all_of("d")))
# Output:
# Error in `all_of()`:                                                                                                                                    
# ! Can't subset columns that don't exist.
# ✖ Column `d` doesn't exist.

Cheers!

@lgaborini
Copy link

Interestingly, I get the cryptic error with any_of() but not with all_of() (as above):

vroom(I(foo), delim=",", col_select=c(any_of("d")))
#> Error in UseMethod("collector_value"): no applicable method for 'collector_value' applied to an object of class "c('collector_skip', 'collector')"

On {vroom} 1.6.5.

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