Multiple box plots

I do not understand how your data are structured. In particular, the y axis variable of a box plot should have continuous values, not two character values. Please make a Reproducible Example if the following code does not help you enough to solve your problem.

set.seed(10)
DF <- data.frame(Cat = sample(c("A", "B"), 50, replace = TRUE),
           Surv = sample(c("1", "2"), 50, replace = TRUE),
           Value = rnorm(50))
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.5.3
ggplot(DF, aes(x = Cat, y = Value, color = Surv)) + geom_boxplot()

Created on 2019-12-20 by the reprex package (v0.3.0.9000)

1 Like