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 categorical variable on the x axis (system) against another categorical 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.
library(ggplot2)
library(ggridges)
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))+
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!
it would be easier if you drew what you want because as described it isn't super clear