具有三个度量的分组条形图

Grouped Barplot with three measures

我正在尝试在 R 中重现以下通过 Excel 生成的图表。

CSV 文件包含以下内容:

> myd
  type       am      tae      tac
1   kA 81.73212 73.07151 26.92849
2   kI 78.87324 84.50704 15.49296
3   kL 82.52184 69.91262 30.08738
4   kS 82.67147 69.31411 30.68589
5   sA 81.67176 73.31295 26.68705
6   sI 79.54135 81.83460 18.16540
7   sL 81.58485 73.66061 26.33939
8   sS 82.09616 71.61536 28.38464

以下 R 代码在 y 轴上创建 am,但我还想添加 taetac

ggplot(myd, aes(x=type, y=am)) + geom_bar(stat="identity")

你知道我如何在 R 中添加它以使其像 Excel 图表中那样吗?

尝试

library(tidyr)
library(dplyr)
library(ggplot2)
gather(myd, Var, Val, am:tac) %>% 
       ggplot(., aes(x=type, y=Val))+
       geom_bar(aes(fill=Var), position='dodge', stat='identity')+
       coord_flip()
require(reshape2)
myd_molten <- melt(data = myd, id.vars = "type")

require(ggplot2)
ggplot(myd_molten, aes(x = type, y = value, fill=variable)) + 
  geom_bar(stat="identity", position=position_dodge())+
  coord_flip()