汇总值并在条形图中显示

Aggregate values and display in barplot

我有以下矩阵:

group,value
a,2
b,4
a,3
a,2
b,5

我想按组聚合它并在条形图中可视化它:

9   --
8    
7 -- 
6   
5   
4   
3   
2   
1   
-------
  a  b

barplot(as.matrix(aggregate(csv[2], csv[1], sum)))

我得到以下情节:

因此两组都只有 1 个柱。如何显示 2 个条(每组 1 个)?

将组设置为行名将产生 2 个柱:

barplot(t(as.matrix((data.frame(aggregate(csv[2],csv[1],sum),row.names=1)))))