我有一個資料集,其中包含每個參與者的大約 35-37 個測驗。是這樣的:
| 參與者_ID | 測驗編號 |
|---|---|
| 71822 | 2125 |
| 71822 | 2167 |
| 71822 | 2145 |
| 71822 | 2189 |
| 71822 | 2143 |
資料包含每個參與者的 35-37 行及其各自的測驗結果。
我想自動化這個任務,我可以檢查任何參與者的測驗是否小于 35 那么它應該說 False 否則為 True。
我嘗試執行以下操作以檢查每個參與者是否至少存在以下測驗
test_ID <- c("2125", "2167", "2145", "2189", "2143")
dat %>%
group_by(Paticipant_ID) %>%
test_ID %in% as.matrix(dat$Test_ID)
uj5u.com熱心網友回復:
要測驗每個參與者有多少行:
library(tidyverse)
data %>% group_by(Participant_ID) %>% count()
顯示缺少哪些組合:
# get a list of every combination of participant and test
allOptions <- expand.grid(unique(data$Participant_ID), unique(data$Test_ID))
names(allOptions) <- names(data)
# look for missing ones
anti_join(allOptions, data)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/537553.html
標籤:r循环
上一篇:基于單元格值的回圈和粘貼
下一篇:在r中的for回圈中從模型中保存
