【发布时间】:2013-10-02 06:32:45
【问题描述】:
我想用 ggplot 绘制数值向量中值的频率。使用plot() 非常简单,但使用 ggplot 无法获得相同的结果。
library(ggplot2)
dice_results <- c(1,3,2,4,5,6,5,3,2,1,6,2,6,5,6,4)
hist(dice_results)
ggplot(dice_results) + geom_bar()
# Error: ggplot2 doesn't know how to deal with data of class numeric
我应该为ggplot() 创建一个数据框来绘制我的向量吗?
【问题讨论】:
标签: r vector ggplot2 histogram