R:一侧截断平均值(R: one side truncated mean)

编程入门 行业动态 更新时间:2024-10-28 11:23:42
R:一侧截断平均值(R: one side truncated mean)

我是R和这个论坛的新手,很抱歉这些愚蠢的问题。

我有一组反应时间数据(每个参与者约200个响应),但在计算平均值之前,我想将每个参与者的10%最慢响应定义为异常值并将其删除。

例如:如果我有20个值,我想切断它们中最慢的2个(= 10%)...

我觉得在R中应该有一个简单的方法,但我不知道如何开始。

提前致谢!

I'm new to R and this forum so sorry for stupid questions.

I have a set of reaction time data (~200 responses per participant) but before calculating the mean I want to define the 10% slowest responses of each participant as outliers and cut them off.

For example: If i have 20 values I want to cut off the 2 slowest of them (=10%)...

I feel like there should be an easy way to do so in R, but I have no idea how to start.

Thanks in advance!

最满意答案

您可以使用分位数来帮助解决这个问题。 例如:

data <- c(1, 2, 3, 4, 5, 6, 7, 8, 9 ,10) mean(data) > 5.5 #Restrict to data that is above 10th percentile mean(data[data > quantile(data, .10)]) > 6

You could use quantile to help with this. For example:

data <- c(1, 2, 3, 4, 5, 6, 7, 8, 9 ,10) mean(data) > 5.5 #Restrict to data that is above 10th percentile mean(data[data > quantile(data, .10)]) > 6

更多推荐

本文发布于:2023-08-03 07:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1385339.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:平均值   side   truncated

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!