I have a data.table dt
:
library(data.table)
dt = data.table(a=LETTERS[c(1,1:3)],b=4:7)
a b
1: A 4
2: A 5
3: B 6
4: C 7
The result of dt[, .N, by=a]
is
a N
1: A 2
2: B 1
3: C 1
I know the by=a
or by="a"
means grouped by a
column and the N
column is the sum of duplicated times of a
. However, I don't use nrow()
but I get the result. The .N
is not just the column name? I can't find the document by ??".N"
in R. I tried to use .K
, but it doesn't work. What does .N
means?