my problem bit more complicated 1 this question . i wanted stack 10 abundant species per each rot.herb (18 of them in total) , group other species 2 big categories, other monocots , other dicots. think need manually assign monocot dicot. tricky part 10 abundant species group unique every rot. herb. here graph of stacked: and here code: weedweights<-weeds%>% select(-ends_with("no"))%>% gather(key=species, value=speciesmass, digsawt:pollawt)%>% mutate(realmass=speciesmass * samplearea.m.2.)%>% group_by(rot.herb, species)%>% summarize(avgrealmass=mean(realmass, na.rm=true))%>% filter(avgrealmass != "nan")%>% ungroup() ggplot(weedweights, aes(x=rot.herb, y=avgrealmass, fill=species))+ geom_bar(stat="identity") you can see data here structure(list(rot.herb = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l...