[R] Frequency of Combinations

abo dalash abo_dlsh at hotmail.com
Mon Apr 24 07:07:21 CEST 2017


Hi there

I have data set with 500,000 patients (rows) and the first column is Patient I'D Number, columns from 2 to 20 are Drug1,Drug 2,...,Drug 20 so each row starts with the patient ID and the remaining of cells in the row are codes for names of the treatments taken by the patient. Number of treatments differ between patients. For example, there are patients with 3 treatments only and patients with 20 drugs. The unique number of treatments in the entire data set is about 6700 drugs. However, I'm interested in studying only 128 drugs, these drugs are listed in a second sheet as code numbers associated with their meanings (names of drugs representing the code). I'm interested in identifying the most frequently used DRUG COMBINATIONS between only the 128 drugs among the 6700 drugs. The structure of the Excell file to be used in analysis is like this:

-Sheet 1( the entire data set):-
1   Patient ID    Drug1    Drug2 ....    Drug 20.
2  1125            45            46                55
3  1126              60           55                 45
.
.
500,000

-Sheet 2 (list of codes meanings for only the drugs of interest):

1    Drug code             meaning
2    45                            Simvastatin
3    55                            Aspirin
4    60                            Paracetamol
.
128

The desired output I'm looking for :

 Drug codes      Meaning          Frequency
45+55               Simvastatin              2
                         +Aspirin
60+55             Aspirin+                       1
                        Paracetamol
60+45             Simvastatin+                1
                        Paracetamol

Please note the the final output does not include any combination containing drug 46 as this is not in the list of drugs preferred to be studied which are mentioned in sheet 2.

Could you please help me which R codes and packages should be used to run this analyisis?

Regards
Mustafa

	[[alternative HTML version deleted]]



More information about the R-help mailing list