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

Documentation: more explicit that j can be logical (when with=FALSE) #1978

Closed
Henrik-P opened this issue Jan 5, 2017 · 3 comments
Closed

Documentation: more explicit that j can be logical (when with=FALSE) #1978

Henrik-P opened this issue Jan 5, 2017 · 3 comments
Milestone

Comments

@Henrik-P
Copy link

@Henrik-P Henrik-P commented Jan 5, 2017

I stumbled over one of the highly informative error messages in data.table:

When with=FALSE, j-argument should be of type logical/character/integer indicating the columns to select.

However, the fact that j can be of type logical is not explicitly described in ?data.table.

From with:

When with=FALSE j is a character vector of column names, a numeric vector of column positions to select or of the form startcol:endcol

From j:

When with=FALSE, j can only be a vector of column names or positions to select

@Henrik-P Henrik-P changed the title Documentation: more explicit that j can be logical when with=FALSE Documentation: more explicit that j can be logical (when with=FALSE) Jan 5, 2017
@franknarf1
Copy link
Contributor

@franknarf1 franknarf1 commented Jan 5, 2017

Fyi, if you're writing new code and using version 1.9.8+, you might as well skip the with=FALSE bit:

library(data.table)
DT = data.table(a = 4, b = 5)
DT[, 2]
DT[, 2, with=FALSE] # same

@Henrik-P
Copy link
Author

@Henrik-P Henrik-P commented Jan 5, 2017

Thank you for the heads-up! Yes, I was aware of that. It was actually after reading the NEWS "Changes in v1.9.8", section 3 about with= that I started to play around with simple (and sometimes veery stupid...) examples. I then stumbled over the error message, which led me to think about logical j and how it was described in the docs. Cheers.

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented May 24, 2017

Funnily, I don't see the fact that j can be logical in the documentation for [.data.frame either...

mattdowle added a commit that referenced this issue Jun 3, 2017
Closes #1978 -- better documentation of logical column selection in j
@mattdowle mattdowle added this to the v1.10.6 milestone Jun 3, 2017
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

4 participants