Linked Questions

Popular Questions

I want to compare two parameters via boxplot in ggplot2

Asked by At

I want to make comparison of two parameters (HF with VF) in boxplot. I am using ggplot. However, when I facet, comparison doesn't work and when I compare, facet does not. Can someone please help?

I am trying to make boxplot in ggplot. But I get something like this

enter image description here

summary(COD)
COD$Treatments <- factor(COD$Treatments, 
                         levels = c("HF,0 h", "HF,24 h", "HF,48 h", "HF,72 h",
                                    "VF,0 h", "VF,24 h", "VF,48 h", "VF,72 h"))
COD$Type_f = factor(COD$Type, levels=c('T1','T2','T3'))
p11 <- ggplot(COD, aes(Treatments, Copy.Number, 
                       fill=interaction(Treatments, Type), 
                       dodge=Type)) +
  stat_boxplot(geom ='errorbar')+ 
  geom_boxplot() +
  facet_grid(.~Type_f) 

What I want is something like this

enter image description here

In my case, HF can be compared with VF side by side.

Related Questions