如何计算R中95个百分点的中位数和平均值
How to calculate a median and mean of 95 percentile in R
我的数据集包含不同物种 (aapl2) 的多个观测值 (平均强度 gfp)。每个物种都有若干个观测值。
我已经按物种对观察结果进行了分组,并计算了 95%:
data2 = aggregate(data$"Mean Intensity gfp" ~ data$aapl2, FUN = quantile, probs = c(0.95)).
但是现在,我遇到了问题,不知道如何解决。
我需要计算一个 95% 的中位数和平均值,但我真的不知道该怎么做。
有人可以帮帮我吗?
非常非常感谢
enter image description here
使用鸢尾花...获取 mean/median 值低于(其物种)第 95 个百分位数的那些
library(data.table)
data.table(iris)[, keep := Petal.Length < quantile(Petal.Length, 0.95),
by = Species][
keep==TRUE,
.(mean(Petal.Length), median(Petal.Length)),
by = Species]
并使用 dplyr
library(dplyr)
iris %>%
group_by(Species) %>%
filter(Petal.Length < quantile(Petal.Length, 0.95)) %>%
summarize("mean"=mean(Petal.Length),
"med"=median(Petal.Length))
我的数据集包含不同物种 (aapl2) 的多个观测值 (平均强度 gfp)。每个物种都有若干个观测值。
我已经按物种对观察结果进行了分组,并计算了 95%:
data2 = aggregate(data$"Mean Intensity gfp" ~ data$aapl2, FUN = quantile, probs = c(0.95)).
但是现在,我遇到了问题,不知道如何解决。 我需要计算一个 95% 的中位数和平均值,但我真的不知道该怎么做。
有人可以帮帮我吗?
非常非常感谢
enter image description here
使用鸢尾花...获取 mean/median 值低于(其物种)第 95 个百分位数的那些
library(data.table)
data.table(iris)[, keep := Petal.Length < quantile(Petal.Length, 0.95),
by = Species][
keep==TRUE,
.(mean(Petal.Length), median(Petal.Length)),
by = Species]
并使用 dplyr
library(dplyr)
iris %>%
group_by(Species) %>%
filter(Petal.Length < quantile(Petal.Length, 0.95)) %>%
summarize("mean"=mean(Petal.Length),
"med"=median(Petal.Length))