Hi everyone. I've been trying to learn how to use ggplot2 to make a presentable dotplot, and for the most part it seems doable. However, one major issue so far is that R seems to automatically rearrange the variables on the X axis in alphabetical and/or numerical order.
So what I've tried so far is setting the scale to discrete(?):
scale_x_discrete(limits = c("PC50", "P50", "PC100", "P100", "OC50", "O50", "OC100", "O100", "POC50", "PO50", "POC100", "PO100", "Autofluor"))
(This is also the vertical order in which these categorical variables appear in my data file)
But the addition of this line doesn't seem to change anything. Am I missing a piece of code that tells R to use this particular order? (Whole code is below)
library(ggplot2)
library(readxl)
#Read data file
AT1910 <- read_excel("F:/Data/AT19-10/Final Analysis/AT1910.xlsx")
scale_x_discrete(limits = c("PC50", "P50", "PC100", "P100", "OC50", "O50", "OC100", "O100", "POC50", "PO50", "POC100", "PO100", "Autofluor"))
#Cd11c Data Live gate
dataLiveCd11c <- ggplot(AT1910, aes(x = Condition, y = `live Cd11c MFI Mean`)) +
geom_dotplot(binaxis = 'y', stackdir = 'center',
stackratio=1.0, dotsize=0.8)
dataLiveCd11c
#Mhc2 Data Live gate
dataLiveMhc2 <- ggplot(AT1910, aes(x = Condition, y = `live Mhc2 MFI Mean`)) +
geom_dotplot(binaxis = 'y', stackdir = 'center',
stackratio=1.0, dotsize=0.8)
dataLiveMhc2