Wanting to plot multiple categorical variables... any help? Cowplot?

Hi R Community!

I am looking to plot multiple categorical variables (camp_1, camp_2, camp_3, camp_4, camp_5, camp_6 below) on the same axis and plot them against a success variable e.g. count on the other axis. The data response can only be '1' or '0'. I've been doing some research and think that the 'cowplot' package would enable me to do it, I'm just not sure how! Any advice?

Screenshot 2021-06-03 at 22.32.49

Thank you very much!

Try this. You want to pivot the "Camp" columns so there's a new column with values "Camp_1", "Camp_2", ...and a new column with values 0, 1, ...

It's a lot more powerful to work with data in this long format.

Take a look at the intermediate result after the pivot_longer command.

df %>%
  pivot_longer(starts_with("Camp")) %>%
  ggplot() +
  aes(name, value) + 

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.