Reputation: 31
I've made a faceted a box plot using two variables. How can I put headers for the facet?
library(ggplot2)
ggplot(data = data60 ,aes(x = education_level, y = lw)) +
geom_boxplot() +
facet_grid(rns~smsa) +
labs(x = "Education Level", y = "Log Wage") +
theme_bw()
Upvotes: 1
Views: 176
Reputation: 72994
You may newly create a factor variable out of your facet variable and use it to facet.
library(ggplot2)
mpg$drv.f <- factor(mpg$drv, labels=c("label1", "label2", "label3"))
p <- ggplot(mpg, aes(displ, cty)) + geom_point()
p + facet_grid(rows = vars(drv.f))
Upvotes: 2