Given are a group indicator variable and some values within groups:
group = rep(c(1,2), each = 3) val = letters[1:6] cbind(group, val) group val [1,]