Here is a classic solution. (Supposing your dataframe is named df
)
data <- tapply(df$total_dist, list(df$groupname,df$bin), sum)
barplot(data,beside=T,col=c("#ee7700","#3333ff")
,main="European Parliament Elections",xlab="Group",ylab="Seats")
legend(locator(1),rownames(data),fill=c("#ee7700","#3333ff"))
and here is solution using ggplot2
library(ggplot2)
qplot(factor(bin),data=df,geom="bar",fill=groupname,weight=total_dist,position="dodge",
main = "European Parliament Elections", xlab="Group",ylab="Seats")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…