To subset a data.table
in R, you can use the i
argument. The syntax for subsetting is:
main.r13 chars2 lines
where DT
is the data.table
, i
is the logical condition to filter rows, j
is the columns to select, and by
is the grouping variable.
Here's an example of filtering a data.table
using the i
argument:
main.r196 chars8 lines
Output:
main.r48 chars5 lines
In this example, we filtered the rows of DT
where z == TRUE
using the i
argument.
gistlibby LogSnag