我知道这可能是一个基础问题,但是我在从包含以下数字的单个向量(dat)绘制直方图时遇到一些问题:
30.90 31.00 32.75 32.65 32.50 31.60 31.80 30.70 31.20 28.10 29.50 28.60 31.70 33.10
使用qplot很简单:
qplot(PorData, binwidth=1.0, geo="histogram", xlab="Data", ylab="Frequency")
这给我提供了一个默认的直方图:
![enter image description here](https://istack.dev59.com/bBkYr.webp)
![enter image description here](https://istack.dev59.com/704LO.webp)
我知道这可能是一个基础问题,但是我在从包含以下数字的单个向量(dat)绘制直方图时遇到一些问题:
30.90 31.00 32.75 32.65 32.50 31.60 31.80 30.70 31.20 28.10 29.50 28.60 31.70 33.10
使用qplot很简单:
qplot(PorData, binwidth=1.0, geo="histogram", xlab="Data", ylab="Frequency")
ggplot2
```。dat <- scan(textConnection("30.90 31.00 32.75 32.65 32.50 31.60 31.80 30.70 31.20 28.10 29.50 28.60 31.70 33.10"))
library(ggplot2)
qplot(dat, binwidth = 1.0, geom = "histogram", xlab = "Data", ylab = "Frequency",
y = ..density.., fill = I("white"), colour = I("black")) +
stat_density(geom = "line")
这里使用y = ..density..
来在y轴上使用相对频率。
qplot
只是一个简化的ggplot
函数,它们的功能相同,但提供不同的接口。请注意,这种类型的问题在CV上是不相关的,因为它们与统计学等无关。 - Tim