Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stephenturner/8dfacf6bf8da3566639246751ffd8583 to your computer and use it in GitHub Desktop.
Save stephenturner/8dfacf6bf8da3566639246751ffd8583 to your computer and use it in GitHub Desktop.
library(tidyverse)
d <- tibble::tribble(
~disease, ~gene, ~chr, ~inheritance,
"flu", "x", 1L, "infectious",
"flu", "y", 2L, "infectious",
"flu", "z", 3L, "infectious",
"aids", "x", 1L, "st",
"aids", "p", 4L, "st"
) %>% print()
d %>%
group_by(disease) %>%
mutate_at(vars(gene, chr), ~paste(., collapse=";")) %>%
ungroup() %>%
distinct()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment