So I have a dataset (output below), and my goal is to have boxplot and plots side by side. (see diagram below)
library(tidyverse)
DataSet <- read.csv("filelocation")
ggplot(data = DataSet,
aes(x = id,
y = result)) +
geom_boxplot(aes(color = live)) +
facet_wrap( ~ resource, scales = "free_y")
For example with this dataset, c3 would have a boxplot for True, but to the right of it, plot points for False.
dput output:
structure(list(id = c(101L, 101L, 101L, 101L, 102L, 102L, 102L,
102L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 104L, 104L, 104L,
104L, 104L, 105L, 106L, 106L, 106L, 106L, 106L, 107L, 107L, 107L,
107L, 108L, 108L, 109L, 109L, 109L, 109L, 109L, 109L, 109L, 109L,
109L, 109L), resource = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L), .Label = c("a", "b"), class = "factor"), result = c(2.12,
4.72, 4.17, 5.53, 3.6, 3.31, 3.64, 5.33, 4.32, 5.48, 5.93, 3.4,
3.09, 5.91, 2.93, 1.81, 3.93, 2.22, 4.77, 3.92, 4.08, 3.65, 5.23,
3.74, 4.03, 3.54, 4.29, 4.3, 2.82, 2.89, 5.41, 4.61, 4, 5.92,
1.66, 1.65, 1.91, 2.69, 5.28, 2.24, 3.64, 4.77), live = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c("f", "t"), class = "factor")), class = "data.frame", row.names = c(NA,
-42L))
I'd also ideally like to be able to separate the groups with a dividing line, like in the diagram. I've read some R resources but haven't seen any hint that it can be done.