I want to list all Patient_code who have taken Botox and Non-Botox.
Below is my Primary table
library(tidyverse)
primary_table <- tibble::tribble(
~Patinet_code, ~Brand_Name,
"Patient-1", "Botox",
"Patient-2", "Botox",
"Patient-2", "Botox",
"Patient-2", "Botox",
"Patient-1", "Non-Botox",
"Patient-2", "Non-Botox",
"Patient-3", "Non-Botox",
"Patient-3", "Non-Botox",
"Patient-3", "Non-Botox"
)
My end result should look like this:
result <- structure(list(Patinet_code = c("Patient-1", "Patient-2")), .Names = "Patinet_code", row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))
I can easily eyeball and I know Patient-1 has taken Botox and Non_Botox. Also, Patient-2 has taken Botox and Non_Botox. Therefore, only those Patinets should be on my list. However, I have list of 1000+ patients. How can I do it using tidyverse tools.
I don't have my codes to show you, it's really embarrassing but I really don't know where to start. Can you please help me. I have used Dplyr common verbs but never solved anything like this before.
Thank you