The base
R
approach would be to use tapply
If your data.frame was called aa
sumById <- with(aa, tapply(l1,id, sum)))
barplot(sumById)
If you wanted to plot your results without explicitly presumarizing, then you could use ggplot2
and stat_summary
library(ggplot2)
ggplot(aa, aes(x = id, y = l1)) + stat_summary(fun.y = 'sum', geom = 'bar')