0

I was hoping somebody could help me with a plot I want to make. I have a dataset of patients admitted during the COVID-19 pandemic concerning their psychological outcomes over time. Within this group, we are interested in the difference between patients who were actually diagnosed with COVID-19 and patient who were not (COVID-19 vs. non-COVID-19) but also in the difference between patients diagnosed with COVID-19 who were admitted to the ICU and who were not admitted to the ICU (COVID-19 ICU vs. COVID-19 non-ICU).

I want to make a boxplot of the outcomes over time (1 month, 3 months and 12 months) with a first boxplot representing the median of the overall population, thereafter the boxplots of the COVID-19 and non-COVID-19 subcohort, and thereafter the boxplot of the COVID-19 ICU and non-ICU cohort, see the image for how I want my plot to look like.

Can anyone help me how to make such a plot? I cannot figure out how I can make the width of all boxes similar, but have different spaces between the boxplots (a large space between the entire cohort, the COVID-19 and non-COVID-19 cohorts and the ICU and non-ICU cohort, and small spaces between the comparisons (so between COVID-19 and non-COVID-19 and between ICU and non-ICU).

enter image description here

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
Hans
  • 1
  • 3
    See [How to make a great R reproducible example]( https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) – TarJae Feb 23 '22 at 17:20
  • You may want to try `facet_wrap()`, or making separate plots and then combining using `patchwork` or `cowplot`. – zephryl Feb 23 '22 at 17:32
  • Please share a reproducible dataset using the `dput` function. Here is how: https://youtu.be/3EID3P1oisg – Shawn Hemelstrand Feb 26 '22 at 01:35

0 Answers0