r - 在 `geom_bar()` 中找不到对象
问题描述
我想映射prop
到条形图上的 y 轴,但我不断收到“找不到对象”错误。如何修复我的代码?谢谢!
dput(starwars_age)
structure(list(`Age Response` = c("> 60", "18-29", "30-44", "45-60"
), n = c(193L, 180L, 207L, 240L), prop = c(0.206196581196581,
0.192307692307692, 0.221153846153846, 0.256410256410256)), row.names = c(NA,
-4L), class = c("tbl_df", "tbl", "data.frame"))
starwars_age %>%
mutate(`Age Response` = factor(`Age Response`, levels = c("18-29","30-44","45-60","> 60"))) %>%
ggplot(aes(x = `Age Response`))+
geom_bar(aes(y = prop))
Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomBar, : object 'prop' not found
解决方案
推荐阅读
- r - 将变量交互作为例行程序创建
- javascript - 有没有办法在 React 中使部分模板字符串变为粗体?
- javascript - JavaScript - 替换正则表达式模式的第 n 个索引
- mongodb - 在 MongoDB 中逐步根据属性值查找文档
- spring - WebClient 发布:WebClientResponseException$InternalServerError
- java - 如何使用服务检查camunda中是否存在流程定义键?
- scala - 如何为 Akka Http Websocket 连接获得每个用户的终止开关?
- python - Python“for循环”循环时间限制
- javascript - 如何使用 react-router、浏览器历史记录存储页面会话?
- postgresql - 如果在高负载情况下使用 HDFS 作为文件系统部署 PostgreSQL 会发生什么?