Use Anova to compare changes in categorical variable over time in R

95 Views Asked by At

I am trying to compare the prescribing of 7 medications pre and post an intervention in 3 groups. I have columns for each other medications with flags of 1 or 0 if prescribed and labels that are pre_econ, post_econ, pre_nocon, post_nocon, pre_inp, post_inp.

The data are formatted like this:

enter image description here

I would like to compare the change in prescribing of the medications (flag = 1) for each other groups so I would get something like this:

enter image description here

I tried prop.table but I do not know how to take the calculated percentages and make a change (from pre post) or how to compare the change.

0

There are 0 best solutions below