I'm trying to plot categorical data using ggplot in which I have two categories for parameter ( C and C+Fe) that I pass facet-grid argument. here is part of my code:
mediagene<-ggplot(ARG)+
geom_boxplot(aes(x = gene, y= RA, fill=type))+
ylab("Relative gene abundance\n copies/ 16s rRNA")+
theme_bw()+
facet_grid(parameter~.,switch="y")+
scale_fill_manual(values=cols)+
labs(fill="Saturation")
and here is the result: enter image description here
now my question is that how I can have only the top graph ( only category C from the parameter)
One way to do this without adding additional packages is to use the subset()
function as in:
mediagene<-ggplot(subset(ARG, parameter == 'C'))+
geom_boxplot(aes(x = gene, y= RA, fill=type))+
ylab("Relative gene abundance\n copies/ 16s rRNA")+
theme_bw()+
facet_grid(parameter~.,switch="y")+
scale_fill_manual(values=cols)+
labs(fill="Saturation")