I have 5 columns of numerical data (Equipment, Hyiene.items etc) and 1 column of categorical data (A or D). I'd like to make a grouped boxplot of the numerical data grouped by category but I cannot find a way:
head(sc)
Equipment Hygiene.items Patient Near.bed Far.bed Care
1 0 0 1 5 1 D
2 1 4 1 2 0 D
3 3 1 1 2 0 D
4 0 2 2 3 1 A
5 1 2 1 5 2 A
6 1 2 1 1 1 A
boxplot(sc~sc$Care)
would seem like the most appropriate way right?
I like ggplot2 but it doesn't look like i can simply do this:
ggplot(sc, aes(y=sc)) +
geom_boxplot(aes(fill=Care))
EDIT: What I like the look of:
I think what I'm after is something like this one I made in Matlab (a long time ago):
Or the 4th graph on here: Plotly
What I have so far:
library(ggplot2)
library(RColorBrewer)
ggplot(melt_A,aes(x=Care,y=value,fill=Care))+geom_boxplot(ylim=c(1,6,1))+facet_grid(~variable)+
labs(x = "Care", y = "Surface contacts",color="Care" )+
scale_y_continuous(limits = c(-0, 6))+
scale_fill_brewer(palette="Purples")+
theme_bw()+
theme(strip.background=element_rect(fill="black"))+
theme(strip.text=element_text(color="white", face="bold"))
Question
How can I change the Care labels from D, H, Me, to something else? e.g. Direct Care, Housekeeping, Medication round, etc...
Fixed:
Found answer here : Stack
I added the following to my ggplot command
scale_fill_brewer(palette="Purples",
labels = c("Direct care", "Housekeeping","Medication round","Mealtimes","Miscellaneous care","Personal care"))