Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 返回计数为1的几何图形条_R_Ggplot2_Geom Bar - Fatal编程技术网

R 返回计数为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

我正试图从数据帧中绘制条形图。酒吧高度全部返回为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 %>%
       ggplot(aes(x = country, y = confirmed)) +
       geom_bar(stat = "identity")

欢迎来到SO。一旦你能做到这一点,请不要忘记接受你自己的答案——这样这个问题就不会再出现没有答案的情况了!谢谢,但上面说我得等两天,因为答案是我自己的。但我会记得回来的!作为一个额外的小信息-使用
geom\u col
geom\u bar(stat='identity')相同。
很高兴知道这一点:)