I have been trying to work with data.table as much as I can. But I do not always fully understand the syntax. I found this line in my code, but I cannot figure out what it does. Could someone perhaps explain it to me?
df <- setDT(df)[, .SD[1], by = .(ID, year)]
It especially concerns he [1]
in SD[1]
. Does it have something to do with subsetting to one row per ID-year?