How may I add the amount of variables (e.g. n=5) of each data.frame on the x-axes to the ggplot?
Tried it with stat_summary. No success.
Thanks in advance for any help!
Can you show what you've tried so far? It would be easier for everyone if you do this using reprex:
library("ggplot2")
library("ggthemes")
library("scales")
RF<-subset(siteData_day_list, siteData_day_list$Method_Org=="RKM / SS" &
siteData_day_list$ParameterName=="Acesulfame" &
siteData_day_list$ParameterName!="Acesulfame-K" &
siteData_day_list$DateTime>="2017-11-01 00:00:00")
RFV<-subset(RF, RF$SiteCode=="RF-V")
RFV_B4<-subset(RF, RF$SiteCode=="RF-V-B4")
RFV_AK3<-subset(RF, RF$SiteCode=="RF-V-AK3")
RFN<-subset(RF, RF$SiteCode=="RF-N")
RFN_B4<-subset(RF, RF$SiteCode=="RF-N-B4")
RFN_AK3<-subset(RF, RF$SiteCode=="RF-N-AK3")
a<-data.frame(group="Filtrate",value=RFV$ParameterValue)
b<-data.frame(group="After SAT",value=RFV_B4$ParameterValue)
c<-data.frame(group="After BAC",value=RFV_AK3$ParameterValue)
d<-data.frame(group="Filtrate ",value=RFV$ParameterValue)
e<-data.frame(group="After AOP",value=RFN$ParameterValue)
f<-data.frame(group="After
AOP+SAT",value=RFN_B4$ParameterValue)
g<-data.frame(group="After
AOP+BAC",value=RFN_AK3$ParameterValue)
plot.data<-rbind(a,b,c,d,e,f,g)
#Plot
ggplot(plot.data, aes(x=group,y=value))+
ggtitle("Acesulfame")+ #Titel
geom_boxplot()+xlab(NULL)+ylab("Concentration [µg/L]")+ #Achsenbeschriftung
geom_hline(yintercept=RFV$LOQ, linetype="dashed", color="blue")+ #LOQ-Linie
geom_vline(xintercept=3.5, color="black", size=1)+ #Trennlinie
theme_few()
I would like to add above or beneath the plot a table with the mean and the amount of variables of each data.frame of the x-axes.
As we do not have your data (essentially, the first lines of code after you call the libraries), your example is not something others can reproduce. To make a reprex (see the link @mishabalyasin provided), the key is not so much your specific data, as what you want to do.
For putting a table below the plot, you might want to look at the gridExtra package.
There's an example with code in the blog post here by Markus Gesmann: