Deleted:How to plot two categoric variables in ggridges
1
0
Entering edit mode
c.e.chong ▴ 10
@cechong-24049
Last seen 2.1 years ago
United Kingdom

Hi,

I have a similar issue to this post- https://stackoverflow.com/questions/52794659/plotting-two-categorical-vectors-in-ggridges

I would like to plot a categoric variable on the x axis (system) against another categoric variable (disease type). However, I want the fluctuation of the curve to represent the proportion of isolates in my dataset that have any one particular system.

Here is an example of my dataframe. I first tried to make the proportion values whole integers, and then use the uncount function to transform the dataset as in the stackoverflow post. This however gave me a multiple curves on the same graphs, rather than one curve fluctuating over the different systems on the x-axis. I think this didn't work as in the stack overflow post the date is still numeric.

df <- data.frame(system=c("AbiC","AbiC","AbiD","AbiD","AbiD","AbiD"), 
                 proportion=c(0.520547945, 1.018220793,11.8630137,5.320813772, 14.46945338, 9.1367713),
                 dataset=c("d1","d2", "d1", "d3", "d2", "d4"))

df$proportion <- as.integer(df$proportion)

df1 <- df %>%
  tidyr::uncount(proportion)
plot_ridge <- ggplot(df1, aes(x= system, y= dataset))+
  ggridges::geom_density_ridges(alpha =0.5, scale =0.5, color="grey90")+
  theme_ridges()
plot_ridge

I'd be really grateful if anyone could help me!

graph ggridges ggplot2 • 444 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 490 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6