我有一个系列的值(即一列数据),我想要创建一个图,其中包含x轴上的数据值范围以及每个值出现在y轴上的数据集中的频率。
我想要的是非常接近
# Kernel Density Plot
d <- density(mtcars$mpg) # returns the density data
plot(d) # plots the results
以及堆栈溢出上的。
然而,我想要频率(相对于密度)在y轴上。
具体来说,我使用的是网络度分布,我想要一个带有开放圆点的双日志规模,即。
我研究过相关的资源和问题,但没有找到我想要的:
R's 的食谱接近我想要的,但不是精确的。我想用“计数”代
我正在创建的替换直方图:1,2,或3次随着时间的推移。因此,每个直方图都显示了给定分钟内的子列数,并给出了次数。直方图对我来说是有意义的,因为在大多数情况下,它们是平滑的(我使用了1分钟的垃圾箱宽度)。没有什么东西看上去太平常了。然而,当我覆盖一个密度图时,左边的尾巴会膨胀,我无法确定其中一个图的原因。
数据集是由从分钟1到最长时间不等的substitions。然后,我把这个数据集切成两半,只看45分钟后潜艇的制作情况。我没有将这些数据折叠回去,我试图创建一个可复制的示例,但无法给出数据。
用于在R中创建的代码
## Filter out subs that are not in the se
我有一个示例脚本,它生成一个带有两个非零柱状图的直方图: library(ggplot2)
# Make a dummy data set, containing 11 values on the interval (1,2), and a
# single value on the interval (3,4)
dftest <- data.frame(dummy_data=c(seq(1.1,1.9,0.08), 3.3))
# Create a histogram with 5 bins, on the interval (0,5)
hst <- ggplot(dfte
我正在使用ggplot2创建一个直方图:
geom_histogram(aes(x=...), y="..ncount../sum(..ncount..)")
我得到了一个错误:
Mapping a variable to y and also using stat="bin".
With stat="bin", it will attempt to set the y value to the count of cases in each group.
This can result in unexpected behavior and
我决定通过我的统计学课程,这是在SPSS,但做在R,因为我想学习统计那里。我目前正在为两个数值连续变体,data$alcohol (酒精滥用量表评分)和data$age做直方图,但被困在第一个。
主要问题是:
我的直方图看起来与答题纸上的图片不同。
我不能添加一个正常的曲线,除非我改变aes为密度,这是我不想做的,因为练习要求频率。
以下是我所写的:
data <- read_excel("~/Dropbox/My Mac (jmbp.local)/Desktop/Kings College London/2021:2022/Statistics/Week 1 s