R ggplot中的堆叠条形图
希望这些年能够并肩而立,但它们似乎是彼此重叠的R ggplot中的堆叠条形图,r,ggplot2,R,Ggplot2,希望这些年能够并肩而立,但它们似乎是彼此重叠的 ggplot(aushealth, aes(x=condition, y=Population, fill=year)) + + geom_bar(stat="identity", position=position_dodge()) 我做错了什么?代码中有一些错误: Condition Year Population Asthma 2001 10.0 Asthma 2017 13.1 Back I
ggplot(aushealth, aes(x=condition, y=Population, fill=year)) +
+ geom_bar(stat="identity", position=position_dodge())
我做错了什么?代码中有一些错误:
Condition Year Population
Asthma 2001 10.0
Asthma 2017 13.1
Back Issue 2001 7.5
Back Issue 2017 6.3
tt=“情况年人口”
哮喘2001 10.0
哮喘2017 13.1
背页2001年第7.5期
2017年第6.3期《退单》
dat您好,请查看关于如何提出有关堆栈溢出的好问题以及如何在R中制作好的可复制示例的指南。它将帮助您更快地获得更高质量的答案。
tt = "Condition Year Population
Asthma 2001 10.0
Asthma 2017 13.1
Back_Issue 2001 7.5
Back_Issue 2017 6.3"
dat <- read.table(text = tt, header = T)
ggplot(dat, aes(x=Condition, y=Population, fill=as.factor(Year))) +
geom_bar(stat="identity", position=position_dodge())