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

“subscript out of bounds” on character vector #20

Open
rossmounce opened this issue Feb 5, 2016 · 2 comments
Open

“subscript out of bounds” on character vector #20

rossmounce opened this issue Feb 5, 2016 · 2 comments
Assignees

Comments

@rossmounce
Copy link

I accidentally input a 'blank' name in a long list of names (an error which I think users are quite likely to make!).

str(A)
 chr [1:337444] "Aa" "Aa" "Aaronsohnia" "Narthecium" "Abarema" ...
lookup_table(A)
Error in FUN(X[[i]], ...) : subscript out of bounds

It would be nice if the lookup_table function could provide a clearer warning about this. Perhaps even print which items in the list are blank OR skip over blank items?

@rossmounce
Copy link
Author

I'm aware this is essentially user error, but I do think this is something that is probably likely to be encountered.

Reproducible example:

oneblank <- readLines("https://gist.githubusercontent.com/rossmounce/39858a08494c46471c71/raw/f2270970025e1184063c4b0c9eeebc1cb48401ca/List%2520with%2520a%2520blank",warn=FALSE)
> head(oneblank)
[1] "Aa"          "Aa"          "Aaronsohnia" "Narthecium"  ""            "Abarema"    
> zzz <- lookup_table(oneblank,missing_action="NA",by_species=TRUE)
Error in FUN(X[[i]], ...) : subscript out of bounds

@richfitz
Copy link
Member

richfitz commented Feb 5, 2016

Thanks Ross. Even if user error, a more informative error message is warranted.

@richfitz richfitz self-assigned this Feb 5, 2016
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