r-根据单独数据帧中的值删除行



我有一个名为corr_dat_cond1的数据帧,它有一个实验任务的试验。

> head(corr_dat_cond1)
participant search_difficulty key_resp.corr key_resp.rt target_position distractor1_colour distractor2_colour non_target_colour
1        1010              easy             1   1.1869998           right          [0,0.5,1]          [0,0.5,1]        [0,0.59,0]
2        1010         difficult             1   1.2490001            down      [0.82,0.31,0]      [0.82,0,0.31]     [0.82,0.31,0]
3        1010              easy             1   1.0100000              up          [0,0.5,1]         [0,0.59,0]        [0,0.59,0]
4        1010              easy             1   0.8659999            down          [0,0.5,1]          [0,0.5,1]        [0,0.59,0]
5        1010         no_search             1   0.8559999           right         [-1,-1,-1]         [-1,-1,-1]        [-1,-1,-1]
6        1010              easy             1   0.6269999           right          [0,0.5,1]         [0,0.59,0]        [0,0.59,0]
non_target_pos cue_uposition target_char non_target_char cue_time           cue_colour cue_validity
1     [0,-0.328]            up           x               =      1.4 Mismatch (Onset) cue        FALSE
2      [0,0.328]          left           x               =      1.0 Mismatch (Onset) cue        FALSE
3      [0.328,0]          down           x               =      1.1 Mismatch (Onset) cue        FALSE
4      [0.328,0]         right           =               x      1.4    Match (Color) cue        FALSE
5     [-0.328,0]          down           =               x      1.4 Mismatch (Onset) cue        FALSE
6     [0,-0.328]         right           =               x      1.4    Match (Color) cue         TRUE

我的第二个数据帧是cond1_participant_meanrts,它为每个search_dffice级别中的每个参与者都有一个high_cutoff和low_cutoff。

> head(cond1_participant_meanrts)
# A tibble: 6 x 6
# Groups:   participant [2]
participant search_difficulty   mrt stdev low_cutoff high_cutoff
<dbl> <chr>             <dbl> <dbl>      <dbl>       <dbl>
1         636 difficult         1.10  0.224     0.426         1.77
2         636 easy              0.986 0.270     0.177         1.79
3         636 no_search         0.909 0.298     0.0160        1.80
4         642 difficult         1.02  0.268     0.221         1.83
5         642 easy              0.887 0.237     0.175         1.60
6         642 no_search         0.809 0.225     0.135         1.48

如果key_resp.rt值大于cond1_participant_meanrts中相应的(基于参与者和search_dffice(high_cutoff值,或者如果key_resp.rt值小于cond1_particulant_meants中相应的low_cutoff,我希望删除corr_dat_cond1中的行。

有办法做到这一点吗?提前谢谢。

这就是您需要的吗?

corr_dat_cond1 %>%
dplyr::left_join(
cond1_participant_meanrts, by=c("participant", "search_difficulty")
) %>%
dplyr::filter(
key_resp.rt < high_cutoff | key_resp.rt > low_cutoff
)

最新更新