View, filter multiple

Hi- having issues with this- any clue what the problem is? I know I'm probably just missing a (

View(df_hospfu %>% filter[(formid == "db23ebb8-5daf-4fe9-8345-e790726139bf"),
(formid == "4d62926b-2910-434e-a2af-3f5c3cb7c084"),
(formid =="a2306025-8a60-4e0e-b21c-82b42f96b1b3"),
(formid =="d3e528cc-3e31-49eb-824b-cc7cfe88c42b"),
(formid =="7232ccd0-c767-4326-a2c3-7757e899eb3a"),
(formid =="09a664e1-7a57-4c3b-9c74-9bac945ea23a"),
(formid =="c45667d8-42d6-460b-9b14-e56ab217508b"),
(formid =="2e5da9cc-697d-44b2-a7e7-174575cb702a"),
(formid =="887358df-249e-4d14-97db-0311193ea034")])

The square brackets are not correct syntax for dplyr filter. and if you want to compare a variables contents to several items its more efficient for you to not retype the name of the variable, but rather check for values in a vector (also less brackets to get confused by)

View(df_hospfu %>% filter(formid %in% c(
  "db23ebb8-5daf-4fe9-8345-e790726139bf", 
  "4d62926b-2910-434e-a2af-3f5c3cb7c084",
  "a2306025-8a60-4e0e-b21c-82b42f96b1b3",
  "d3e528cc-3e31-49eb-824b-cc7cfe88c42b",
  "7232ccd0-c767-4326-a2c3-7757e899eb3a",
  "09a664e1-7a57-4c3b-9c74-9bac945ea23a",
  "c45667d8-42d6-460b-9b14-e56ab217508b",
  "2e5da9cc-697d-44b2-a7e7-174575cb702a",
  "887358df-249e-4d14-97db-0311193ea034"
)))

Awesome; thank you- and if I want to write it to CSV?

write.csv(df_hospfu %>% filter(form.case.@case_id %in% c(
"db23ebb8-5daf-4fe9-8345-e790726139bf",
"4d62926b-2910-434e-a2af-3f5c3cb7c084",
"a2306025-8a60-4e0e-b21c-82b42f96b1b3",
"d3e528cc-3e31-49eb-824b-cc7cfe88c42b",
"7232ccd0-c767-4326-a2c3-7757e899eb3a",
"09a664e1-7a57-4c3b-9c74-9bac945ea23a",
"c45667d8-42d6-460b-9b14-e56ab217508b",
"2e5da9cc-697d-44b2-a7e7-174575cb702a",
"887358df-249e-4d14-97db-0311193ea034")))
"duplicatesinpatientoutpatient_Feb21Monthly.csv", row.names=FALSE)

now there are fewer bracket its easier to count them. you open 3 left ones ((( and close 4 times )))
remove one of the triple closing ))) -> ))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.