3
我想用ggplot绘制来自数值向量的值的频率。与plot()
是相当直接,但我不能与ggplot得到相同的结果。如何使用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()
数据框绘制矢量我?