I am using the Theoph
dataset from the datasets
package in R, as an exercise. I wanted to see if I could get the Time at which each subject achieved their maximal concentration. How can I do this using data.table?
Edit: This is what I tried before, and didn't work:
library(data.table)
theophylline <- as.data.table(Theoph)
theophylline[,.(Time), by = .(by1 = Subject, by2 = conc)]
But got the answer I wanted with @Akrun's code:
theophylline[, Time[which.max(conc)],Subject]