I want to delete certain rows in a data frame when the number of rows with the same index is smaller than a pre-specified value.
> fof.6.5[1:15, 1:3] draw
You could do this using dplyr (assuming your data is in a data frame called dt:
dplyr
dt
dt %>% group_by(draw) %>% filter(n() >= 5) %>% ungroup()
Or you could use table or xtabs:
table
xtabs
tab <- xtabs(~ draw, dt) dt[!dt$draw %in% as.numeric(names(which(tab < 5))), ]