提问人:azimm 提问时间:11/17/2023 最后编辑:stefanazimm 更新时间:11/17/2023 访问量:25
收到 ggplot2 错误,说我的变量是离散的,需要连续的,但它是数字 [closed]
Getting ggplot2 error that says my variable is discrete and needs to be continuous, but it is numeric [closed]
问:
我有一个包含许多变量的数据集,但我只关注用户及其旅程总数
我想制作 TotalJourneys.x 变量的直方图,该变量是数值类。
我跑了一条非常简单的线来得到一个基本的直方图
ggplot(Oct19, aes(x="TotalJourneys.x")) + geom_histogram()
但是我收到此错误:
Error in `geom_histogram()`:
! Problem while computing stat.
ℹ Error occurred in the 1st layer.
Caused by error in `setup_params()`:
! `stat_bin()` requires a continuous x aesthetic
✖ the x aesthetic is discrete.
ℹ Perhaps you want `stat="count"`?
Run `rlang::last_trace()` to see where the error occurred.
我很困惑,因为我的变量已经是数字,而不是字符或因子。在关于此主题的所有其他 stackoverflow 问题中,似乎人们正在使用需要 geom_bar() 的实际离散变量,但据我了解,情况并非如此。
答: 暂无答案
评论