loosely-coupled-dss/results/analysis.R
2021-05-10 11:35:12 +02:00

27 lines
1.1 KiB
R

library("tidyverse")
library("knitr")
data=read_csv("results.csv")
final=data%>%group_by(simkey,wireless,wakeupfor)%>%summarize(wireless=first(wireless),sd=sd(energy),wakeupfor=first(wakeupfor),energy=mean(energy))
ggplot(final,aes(x=simkey,y=energy,fill=wireless))+
geom_bar(stat="identity",position=position_dodge())+
xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(position=position_dodge(0.9),aes(ymin=energy-sd, ymax=energy+sd),width=0.5,size=1.5,) +
facet_wrap(~ wakeupfor) +
geom_text(aes(label = round(energy+sd), y= energy+sd),vjust=-0.4,position=position_dodge(0.9))+
geom_text(aes(label = round(energy-sd), y= energy-sd),vjust=+1.5,position=position_dodge(0.9))+
geom_text(aes(label = round(energy), y= energy/2),fontface="bold",colour="white",position=position_dodge(0.9))
ggsave("figure.png")
tf="tables.org"
write("",file=tf)
for(wake in unique(data$wakeupfor)){
write(kable(final%>%filter(wireless=="lora",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
write(kable(final%>%filter(wireless=="nbiot",wakeupfor==wake)),file=tf,append=TRUE)
write("\n",file=tf,append=TRUE)
}