So I currently face a problem in R that I exactly know how to deal with in Stata, but have wasted over two hours to accomplish in R.
Using the data.frame below, the
The package dplyr makes this kind of things easier.
library(dplyr) mydata %>% group_by(id, day) %>% filter(row_number(value) == 1)
This command requires more memory in R than in Stata: rows are not suppressed in place, a new copy of the dataset is created.