繁体   English   中英

使用ggplot2 - R的geom_bar()查询

[英]Query using geom_bar() of ggplot2 - R

我有一个类似的数据框如下:

mapDF <- structure(list(var = c(11L, 3L, 4L, 15L, 19L, 17L, 1L), approvals = c(10.5233545765422, 
67.9809421770218, 9.66394835013545, 2.93736399165075, 3.36787205222721, 
4.0168261757783, 1.50969267664431)), .Names = c("var", "approvals"
), row.names = c(NA, -7L), class = "data.frame")

当我尝试使用上面的数据框创建条形图时使用:

gplot <- ggplot(mapDF, aes(x= mapDF[1], y= mapDF[2])) + geom_bar()

..我收到以下消息, 没有任何内容出现在RStudio的'Plots'部分:

Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous
Error: stat_bin requires the following missing aesthetics: x

任何人都可以指出我的错误?

滚动@joran的评论回答:

ggplot(mapDF, aes(x=var, y=approvals)) + geom_bar(stat="identity")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM