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)]) > 6You 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更多推荐
发布评论