I have the following boxplots.
How can I separate these boxplots into four group of boxplots.
Top row content separate boxplots of Jerry and Tom showing X and y
Bottom row content separate boxplots of Jerry and Tom showing a and b.
suppressPackageStartupMessages({
library(dplyr, warn.conflicts = FALSE)
library(data.table)
library(ggplot2)
library(tidyr)
})
dat=data.frame(
name=c(rep("Tom",4),rep("Jerry",4)),
Address=c(rep(c("X","y","a","b"),2)),
Price=c(86,84,45,57,85,81,35,41)
)
dat=dat %>%
mutate(Address=factor(Address, levels =unique(Address)))
dat %>%
group_by(name) %>%
ggplot(aes(x = Address, y = Price, fill = Address)) +
geom_boxplot(fatten = 1,outlier.size = 0.8,lwd=0.7) +
facet_wrap(~ name)