R 返回计数为1的几何图形条
我正试图从数据帧中绘制条形图。酒吧高度全部返回为1。以下是可复制代码的示例:R 返回计数为1的几何图形条,r,ggplot2,geom-bar,R,Ggplot2,Geom Bar,我正试图从数据帧中绘制条形图。酒吧高度全部返回为1。以下是可复制代码的示例: df <- data.frame(country = c("China", "USA", "South Korea"), confirmed = c(4747763, 90, 2060)) ggplot(df, aes(x = country, fill = country)) + geom_bar() df明白了。必须设置stat=“identity”以使几何图形条读取y
df <- data.frame(country = c("China", "USA", "South Korea"),
confirmed = c(4747763, 90, 2060))
ggplot(df, aes(x = country, fill = country)) +
geom_bar()
df明白了。必须设置stat=“identity”以使几何图形条读取y轴:
df %>%
ggplot(aes(x = country, y = confirmed)) +
geom_bar(stat = "identity")
欢迎来到SO。一旦你能做到这一点,请不要忘记接受你自己的答案——这样这个问题就不会再出现没有答案的情况了!谢谢,但上面说我得等两天,因为答案是我自己的。但我会记得回来的!作为一个额外的小信息-使用geom\u col
与geom\u bar(stat='identity')相同。
很高兴知道这一点:)