get all combinations from within a variable and another

I want to transform the (3 columns)data set to the (12 columns) dataset.

I just wrote the counts that i need for the first combination of the first ID , however i need to produce these counts for the rest of combinations corresponding to their IDs.

Any help is much appreciated.

df1

One of these options should work:

I tried , but it doesn't work. I need to make combination from within the first column and the second column (i.e each pair from the drug column with the the AE column).

Hello,
I'm sure you shared this image with the best intentions, but perhaps you didnt realise what it implies.
If someone wished to use example data to test code against, they would type it out from your screenshot...

This is very unlikely to happen, and so it reduces the likelihood you will receive the help you desire.
Therefore please see this guide on how to reprex data. Key to this is use of either datapasta, or dput() to share your data as code

Thanks , well noted. I have posted another Topic using reprex , as i realized that this question would produce a huge dataset that R will return an error upon trying to process it. The original dataset itself has more than 200000 record , so making all possible combinations would produce a dataset with more than 76 million record !! R session stopped working when i tried it !

I would really appreciate if you helped me with this. i tried to keep it simple as possible :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.