df <- data.frame(group=c("a", "b"), value=1:8) ## Order the data frame with the variable of interest df <- df[order(df$value),] ## Aggregate aggregate(df, list(df$group), FUN=head, 1)