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

Two dimensional column selector gives different result than data.frame's selector #1259

Closed
JohnMount opened this issue Aug 11, 2015 · 2 comments
Labels

Comments

@JohnMount
Copy link

I noticed data.table's two dimensional selector [,] doesn't pick columns the same way data.frame's does, even though the object claims to be both a data.frame and data.table. Example below:

require(data.table)
data.frame(x=7)[, "x"]
## [1] 7
data.table::rbindlist(list(data.frame(x=7)))[, "x"]
## [1] "x"  # what?
data.frame(data.table::rbindlist(list(data.frame(x=7))))[, "x"]
## [1] 7
class(data.table::rbindlist(list(data.frame(x=7))))
## [1] "data.table" "data.frame"
@ChristK
Copy link

ChristK commented Aug 11, 2015

I would recommend you to have a look at the faq (http://datatable.r-forge.r-project.org/datatable-faq.pdf). Your question is answered in paragraph 1.1

@arunsrinivasan
Copy link
Member

Hi John, also the "Introduction to data.table" vignette from the Getting started page explains the reason/idea behind it under 1. Basics -> g). FAQ 2.17 should be helpful to get an idea of other minor differences.

Once you get familiar with the data.table syntax, you'll find yourself using much less of the data.frame syntax (as you can do much more in the j argument of a data.table). It's just a matter of getting used to.

But we are discussing minimising this aspect of difference as much as possible in #1188.

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

No branches or pull requests

3 participants