0
我想創建不具備條件的病人誰,在多個測試日期查找列表。我查找data.frame超過32892意見長,但這裏是一個小例子查找和刪除變量,基於以下因素
PatientName <- c("Alice", "Tom", "Dave", "Michele", "Wendy", "Alice", "Tom", "Wendy", "Alice", "Wendy")
SubjectiveCondition <- c("Dizziness", "Normal", "OK", "High Heart Rate", "Normal", "Good", "High Heart Rate", "Dizziness", "Normal", "High Heart Rate")
Date <- c("01/09/2017", "01/09/2017", "01/09/2017", "01/09/2017", "01/09/2017", "02/09/2017", "02/09/2017", "02/09/2017", "03/09/2017", "03/09/2017")
lookupdf <- data.frame(PatientName, SubjectiveCondition, Date)
然後我有一個包含每個病人在每個日期生理樣本進行研究實驗data.frame。一個例子是:
PatientName <- c("Alice", "Tom", "Dave", "Michele", "Wendy", "Alice", "Tom", "Wendy", "Alice", "Wendy")
Sample <- c(120, 110, 120, 150, 210, 300, 290, 110, 150, 260)
Date <- c("01/09/2017", "01/09/2017", "01/09/2017", "01/09/2017", "01/09/2017", "02/09/2017", "02/09/2017", "02/09/2017", "03/09/2017", "03/09/2017")
experimentaldf <- data.frame(PatientName, Sample, Date)
我希望在每個日期查找每一個病人,如果他們有「頭暈」或「高心率」,然後從修改experimentaldf
的experimentaldf
我預期的輸出中排除將會是:
PatientName <- c("Tom", "Dave", "Wendy", "Alice", "Alice")
Sample <- c(110, 120, 210, 300, 150)
Date <- c("01/09/2017", "01/09/2017", "01/09/2017", "02/09/2017", "03/09/2017")
revisedexperimentaldf <- data.frame(PatientName, Sample, Date)
這是可以做到的嗎?