I've run into a problem, that I can't seem to solve, and after having searched the internet for 24h I decided to ask in here.
I have a 4 boxplot figure, that I made with the ggplot2. Each boxplot is named after the data variable. But to make it easier for the reader to understand, I would like to change the title of each single boxplot (without changing the name in the data set). Is this possible? I've tried using "ggtitle", "rename", "main=" and several other suggestions, I found on the internet.
Here is the coding I've done:
d11 <- droplevels(subset(d, time=="Baseline" | time=="Pre-ECT" | time=="1st Period Post-ECT" | time=="2nd Period Post-ECT"))
ggplot(melt(d11, id.vars= c("subj", "time", "time.num", "intervention","order", "age", "sex", "diagn", "diagn2"), measure.vars = c("HR", "BPsys", "BPdia", "CO")), aes(x=time, y = value, fill = intervention)) +
geom_boxplot() +
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5)) +
facet_wrap(~variable, scales= "free")
I would like the headings in the boxplots to be "Heart rate", "Systolic blood pressure", "Diastolic blood pressure", "Cardiac output" instead.
Any suggestions to a function, that might work?
labeller
argument to facet_wrap - Richard Telford