R-突变功能中的多个条件
我有以下数据框(请参阅链接:)。现在,我想知道对于每个 Trial_number,response_time_to_origin 中的值是否包含在 target_onset_plus200 和 target_onset_plus1000 之间,但根据多个条件:
if 76 <= Trial_number <= 151,filter block == 1 and subblock == " A”,然后检查response_time_to_origin是否在target_onset_plus200和target_onset_plus1000。如果是这样,请回答“真”,如果其他块和子块也发生这种情况,请回答“假”。
否则,如果152 <= Trial_number <= 227,则过滤块== 1且子块==“B”,然后检查response_time_to_origin是否在target_onset_plus200和target_onset_plus1000之间。如果是这样,请回答“真”,如果其他块和子块也发生这种情况,请回答“假”。
ETC。
我尝试插入以下代码,但这显然不起作用:
response_accuracy=data_out%>%
select(trial_number, response_time_to_origin)%>%
filter(!is.na(response_time_to_origin))%>%
mutate(list_windows_terminals = list(list_hit_windows))%>%
unnest(list_windows_terminals)%>%
group_by(block, subblock, trial_number)%>%
mutate(response_in_window = if(76 <= trial_number <= 151){
filter(block == 1 & subblock == "A") & response_time_to_origin >
target_onset_plus200 & response_time_to_origin <
target_onset_plus1000)})
你能帮我吗?提前致谢 !
I have the following dataframe (see the link : ). Now, I would like to know whether, for each trial_number, the value in response_time_to_origin is contained between target_onset_plus200 and target_onset_plus1000 but according to multiple conditions :
if 76 <= trial_number <= 151, filter block == 1 and subblock == "A" and then check whether response_time_to_origin is between target_onset_plus200 and target_onset_plus1000. If so answer TRUE, if this happens for other blocks and subblock, answer FALSE.
else if 152 <= trial_number <= 227, filter block == 1 and subblock == "B" and then check whether response_time_to_origin is between target_onset_plus200 and target_onset_plus1000. If so answer TRUE, if this happens for other blocks and subblock, answer FALSE.
ETC.
I have tried to insert the following bit of code, which obviously does not work :
response_accuracy=data_out%>%
select(trial_number, response_time_to_origin)%>%
filter(!is.na(response_time_to_origin))%>%
mutate(list_windows_terminals = list(list_hit_windows))%>%
unnest(list_windows_terminals)%>%
group_by(block, subblock, trial_number)%>%
mutate(response_in_window = if(76 <= trial_number <= 151){
filter(block == 1 & subblock == "A") & response_time_to_origin >
target_onset_plus200 & response_time_to_origin <
target_onset_plus1000)})
Could you help me ? Thanks in advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有最少的数据示例,就很难为您提供帮助。
尝试这个代码:
如果它不起作用,您应该提供一个代码来生成您的数据帧供我测试。
It makes it a bit difficult to help you without the minimal example of data.
Try this code:
If it doesn't work, you should provide a code to generate your dataframe for me to test.