Skip to content

Instantly share code, notes, and snippets.

@malcolmbarrett
Created February 12, 2019 20:47
Show Gist options
  • Save malcolmbarrett/b387980cc1beaded3db4826ecf9a0e83 to your computer and use it in GitHub Desktop.
Save malcolmbarrett/b387980cc1beaded3db4826ecf9a0e83 to your computer and use it in GitHub Desktop.
library(tidyverse)
patient_db <- tibble(
patient = c("a", "b", "c"),
RecordAxisCondition1 = c("T400", "I560", "T401"),
RecordAxisCondition2 = c("T402", "N179", "R111"),
RecordAxisCondition3 = c("N180", "X46", "N179")
)
search_codes <- c("T400", "T401", "T402", "T403", "T404", "T406")
patient_db %>%
gather("record", "code", -patient) %>%
group_by(patient) %>%
summarize(tally = sum(code %in% search_codes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment