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

Friendly column finder for "not found" errors #2887

Closed
MichaelChirico opened this issue May 18, 2018 · 1 comment
Closed

Friendly column finder for "not found" errors #2887

MichaelChirico opened this issue May 18, 2018 · 1 comment
Assignees
Milestone

Comments

@MichaelChirico
Copy link
Member

Consider:

DT = data.table(myname = 1, some_var = 2)
DT[somevar == 2]
#  Error in eval(.massagei(isub), x, parent.frame()) : 
#   object 'somevar' not found 

Should be easy enough to run adist on names(DT) (or also ls()) to suggest some potential misspellings. Nothing too sophisticated of course, maybe just look within levensthein distance of 2 or 3. Truncated to 10 options or so in case there are numbered columns.

@HughParsonage
Copy link
Member

Or agrep:

 agrep("somevar", names(DT), value = TRUE)[1]
#> "some_var"

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

No branches or pull requests

4 participants