与下面类似,如果我从SQL获取数据,如何获取输出。
示例数据集:MRN是患者ID
Brand <- c("Evista", "Rozerem", "Altace")
MRN <- c("121212", "121212", "231212", "432123", "432123", "542345",
"323412", "242341", "412111", "642321")
MedList <- c("raloxifene 60mg daily", "Rozerem 8mg daily", "evista 60mg
daily", "metoprolol tartate 25mg twice daily", "ramelteon 8mg daily",
"ramipril 5mg daily", "omeprazole 20mg daily", "ALTACE 5mg nightly",
"ramelteon 8mg daily", "imatinib 400mg daily")
查询:
grepl(paste(toupper(Brand), collapse = '|'), toupper(MedList))
[1] FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
===========================================================
示例:
rm(list=ls()) Brand <- c("Evista", "Rozerem", "Altace")
MRN <- c("121212", "121212", "231212", "432123", "432123", "542345", "323412", "242341", "412111", "642321")
---getting this from data base----
MedList <- data.frame(DiagnosticNotes = data[, "nvchDiagnosticNotes"])
---getting this from data base----
Patients <- data.frame(MRN,MedList)
我是否需要更改以下查询:
grepl(paste(toupper(Brand), collapse = '|'), toupper(MedList))