R-突变功能中的多个条件

发布于 2025-01-18 05:10:29 字数 1232 浏览 1 评论 0原文

我有以下数据框(请参阅链接:response_accuracy)。现在,我想知道对于每个 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 : response_accuracy). 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离旧人 2025-01-25 05:10:29

如果没有最少的数据示例,就很难为您提供帮助。

尝试这个代码:

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 = ifelse(between(trial_number, 76, 151) && block == 1 && subblock == "A", "TRUE", "FALSE")) %>%
   mutate(response_in_window = ifelse(between(trial_number, 152, 227) && block == 1 && subblock == "B", "TRUE", response_in_window))

如果它不起作用,您应该提供一个代码来生成您的数据帧供我测试。

It makes it a bit difficult to help you without the minimal example of data.

Try this code:

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 = ifelse(between(trial_number, 76, 151) && block == 1 && subblock == "A", "TRUE", "FALSE")) %>%
   mutate(response_in_window = ifelse(between(trial_number, 152, 227) && block == 1 && subblock == "B", "TRUE", response_in_window))

If it doesn't work, you should provide a code to generate your dataframe for me to test.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文