Hi Geraldine-

 

Thank you so much- I will try your code.

 

Best,

Nihal

 

From: "Klarenberg,Geraldine" <[log in to unmask]>
Date: Friday, November 9, 2018 at 12:47 PM
To: "El Rouby,Nihal M" <[log in to unmask]>
Cc: UF R Users List <[log in to unmask]>
Subject: Re: Data summarization question

 

Hi Nihal

 

I did something extremely similar for bottom vegetation categories from fishing surveys (finding all the unique combinations). I adapted it to your data, see attached.

Hope this helps.

 

Geraldine Klarenberg, PhD

Post-Doctoral Associate

Department of Wildlife Ecology and Conservation / Agricultural and Biological Engineering

University of Florida

Tel: 352-294-7581

Cell: 386-517-3952

 

 



On Nov 9, 2018, at 10:59 AM, El Rouby,Nihal M <[log in to unmask]> wrote:

 

Dear all- 

 

I have a data wrangling question. I have a data set with IDs and the medications each ID had. I’m interested to know how many were on several medications and what are the most frequent combinations of medications. I was able to use to dplyr and summarize to know the number of IDs on one, two, three, four, etc. My question is: Is there a way to get the name of these combinations and their frequency? In other words, X number of individuals were on combination of A+B, X number of individuals were on combinations A+B+C, and so on.

 

Here is the code I have used and worked for me to get the number on the combinations but I don’t know what these combinations are. I’m attaching a snippet of example data

 

I appreciate your help.

 

Best,

Nihal

 

m <- read_excel("testdata.xlsx")

summarized_count<-m  %>%

    group_by(ID) %>%

   summarise(n_distinct(Medication))

View(summarized_count)

 

table(summarized_count$`n_distinct(Medication)`)

This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. <testdata.xlsx>

 

This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.