列出不符合条件的参与者ID

JJJJJJJ

我正在尝试获取参与者ID的列表,以及他们不符合标准的响应百分比。

我的数据简短版本如下所示(数据名称:MyData):

structure(list(ID = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), .Label = c("rladb11", "rladb7"), class = "factor"), blocknum = c(1L, 
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 1L, 2L, 2L, 2L, 2L, 
2L, 3L, 3L, 3L, 3L, 3L, 4L), latency = c(322L, 277L, 243L, 188L, 
642L, 155L, 122L, 233L, 280L, 142L, 834L, 134L, 744L, 557L, 523L, 
432L, 524L, 534L, 476L, 533L, 967L, 476L, 523L, 555L)), class = "data.frame", row.names = c(NA, 
-24L))

我们需要排除数据响应超过“快速”响应(<300ms)的10%以上的参与者。我们有变量-ID,Blocknum和延迟(速度)。

因此,可能的预期结果将是(使用提供的数据)像:

  1. 参与者ID及其响应/数据比例<300ms的列表。
1. rladb7    0.90

或者如果选项1是不可能的,则2.仅列出参与者ID

rladb7

我一直在尝试逐步执行此操作,并通过group_by函数使用它,但是它似乎没有显示正确的数字。

这是我尝试过的代码和结果:

MyData %>% summarise(length(which(MyData$latency<300)))

  <fct>                                            <int>
1 rladb11                                             9   (<< they are somehow put the total number for both)
2 rladb7                                              9

SpeedCount <- length(which(MyData$latency<300))
SpeedProp <- SpeedCount/nrow(MyData)

[1] 0.375 (<<same as above--this is a proportion of all the fast responses from all the participants out of all the responses from all the participants)

这不太正确。我不确定如何同时完成这两项工作(<300ms的响应数和每个参与者的所有响应中快速响应的比例),这是我期望分别发生的事情:


  <fct>                    <int>
1 rladb11                    9             .90   
2 rladb7                     0             .00

不幸的是,我可能希望看到那些不符合标准的用户(超过10%的响应是<300ms),所以像这样:

  <fct>                    <int>
1 rladb11                    9             .90   

或我上面列出的一个(参与者ID和%的列表,参与者ID的列表,这两个都不符合条件)

是否有最佳解决方案来获取不符合条件的人员名单?

谢谢!

阿克伦

我们可以做一个小组 mean

library(dplyr)
MyData %>% 
     group_by(ID) %>% 
     summarise(Prop = mean(latency <300)) %>%
     filter(Prop > 0)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章