I have a dataframe with three variables:
- ID
- Gender (m,f,d)
- Medication (1,2,3,4,5,6,7,8,9,10)
For "Medication" multiple selections were possible in the questionnaire so now there are several numbers in each cell of the dataframe (separated by ";"). Is it possible to create a frequency table that counts each number (1-10) individually and have it grouped by gender? I need to have "Medication" (1-10) in rows and the counts grouped by gender as columns.
I already tried to split the columns so that each cell is left with only one value. But then I still have the problem to count the values across multiple columns. For each function I tried so far, the variables have been counted separately.
Thank you for your help!
And this is the expected output but without the combinations like "01;03"