Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thank you for the link. I still end up confused.

How does selecting the 3rd column,

    dt[, 3]
jive with

>`DT[i, j, by, ...]` which means: “Take DT, subset rows using i, then calculate j ...

I don’t understand how column selection and calculating an expression is the same thing.

So now I can’t figure out if

    DT[, sum(V1)]
Will return the column indexed at the sum of V1 or if it will return the sum of the column called V1. How can I tell, from the syntax?


j is always for columns.

So for your first example it grabs the third column. The calculation you’re performing is a column selection.

For your second example, you’re returning all the rows, selecting column V1, and summing it.

I really prefer to name the operations

    dt[rows, columns, groups]




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: