I have a dataframe df, containing three vectors:
df
subject condition value 01 A 12 01 A 6 01 B 10 01
Here's a dplyr solution -
dplyr
df %>% group_by(subject, condition) %>% filter(row_number() < 3) %>% ungroup() # A tibble: 8 x 3 subject condition value 1 01 A 12 2 01 A 6 3 01 B 10 4 01 B 2 5 02 A 5 6 02 A 11 7 02 B 3 8 02 B 5