我想做以下程序:我在一側有一個名為 response_time_to_origin 的向量(參見鏈接:response_time_to_origin),在另一側有一個名為 list_hit_windows 的資料框(參見鏈接:list_hit_windows),其中包含 3 列,即。target_onset、target_onset_plus200 和 target_onset_plus1000。在這個資料幀的每一行,target_onset_plus200 和 target_onset_plus1000 應該被認為是區間終端。
通過一些代碼,我想知道對于 response_time_to_origin 的每一行,值是否包含在 list_hit_window 資料幀的一行或多行的 target_onset_plus200 和 target_onset_plus1000 之間(如果是,則回傳 TRUE,如果沒有則回傳 FALSE)。
我該怎么做?
uj5u.com熱心網友回復:
一般來說,我會將 list_hit_windows 添加為 response_time_to_origin 中的新串列列。然后,我將取消嵌套串列列,以便為每個response_time_to_origin. 然后,您可以創建一個虛擬變數來判斷每一行是否符合您的標準
df %>% mutate(meets_criteria = response_time_to_origin > target_onset_plus200 & response_time_to_origin < target_onset_plus1000)
這將根據要求為您提供 TRUE 和 FALSE 列。
你可以看看這個答案的最后一點R - 計算每天/每周的費率,分母的變化是相似的和可重復的,你可以從中學習。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/452787.html
上一篇:PythonFor回圈-列舉
