Ah the forcats library, I see! Thanks.
Hmm... I installed the package and now the code seems to be working, but it is still reordering the variables on the X axis in alphabetical order.
Am I missing something really simple?
library(ggplot2)
library(readxl)
library(forcats)
#Read data file
AT1910 <- read_excel("F:/Data/AT19-10/Final Analysis/AT1910.xlsx")
f <- factor(c("PC50", "PC50", "PC50", "P50", "P50", "P50",
"PC100", "PC100", "PC100", "P100", "P100", "P100",
"OC50", "OC50", "OC50", "O50", "O50", "O50",
"OC100", "OC100", "OC100", "O100", "O100", "O100",
"POC50", "POC50", "POC50", "PO50", "PO50", "PO50",
"POC100", "POC100", "POC100", "PO100", "PO100", "PO100",
"Autofluor"))
fct_inorder(f)
#> [1] PC50 PC50 PC50 P50 P50 P50 PC100 PC100 PC100 P100 P100 P100 OC50 OC50 OC50 O50 O50 O50 OC100 OC100 OC100 O100 O100 O100 POC50 POC50 POC50 PO50 PO50 PO50 POC100 POC100 POC100 PO100 PO100 PO100 Autofluor
#> Levels: 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
EDIT: wait... maybe I should set the x variable in the ggplot function to the factor?
EDIT: Ah, nope. That only changes the x axis name it seems...