gpt4 book ai didi

r - ggplot2中的四分位距

转载 作者:行者123 更新时间:2023-12-05 01:10:08 27 4
gpt4 key购买 nike

set.seed(42)
DF <- data.frame(bias=rnorm(2700),cnd=1:27)
DF$cnd <- factor(DF$cnd)

试图了解 ggplot 中中值的使用。我希望找到一种绘制上下四分位距的方法。但是我在任何地方都找不到“fun.data=median_hilow”的完整解释。即使我认为它正在做正确的事情。是否有关于此函数的完整文档来检查它是如何绘制 IQR 的?
library(ggplot2)
ggplot(DF,aes(x=cnd,y=bias,colour=cnd)) +
stat_summary(fun.data=median_hilow)

最佳答案

median_hilow 只是来自 smedian_hilow 包的 Hmisc 的包装。

来自 smean / smedianHmisc 函数组的文档。

根据@BondedDust 下面的评论,您需要事先安装 Hmisc 包。

(输入 ?smedian_hilow?median_hilow ):

A number of statistical summary functions is provided for use with summary.formula and summarize (as well as tapply and by themselves). smean.cl.normal computes 3 summary variables: the sample mean and lower and upper Gaussian confidence limits based on the t-distribution. smean.sd computes the mean and standard deviation. smean.sdl computes the mean plus or minus a constant times the standard deviation. smean.cl.boot is a very fast implementation of the basic nonparametric bootstrap for obtaining confidence limits for the population mean without assuming normality. These functions all delete NAs automatically. smedian.hilow computes the sample median and a selected pair of outer quantiles having equal tail areas.


smedian.hilow 根据置信区间计算中位数和上下四分位数。举个例子:
x <- rnorm(100)

> smedian.hilow(x, conf.int=.5) # 25th and 75th percentiles
Median Lower Upper
0.02036472 -0.76198947 0.71190404

您可以查看@BondedDust 的答案,了解如何使用 ggplot2 函数实现这一点。

关于r - ggplot2中的四分位距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28436467/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com