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()
數據框繪製矢量我?