library(ggplot2)
library(tidyr)
library(scales)
#faili sisselugemine ja andmete formaadi korrigeerimine
J233=read.csv2("PT2-T2.3-J2.3.3.csv",header=TRUE, encoding ="UTF-8")
names(J233)=gsub("X", "", names(J233))
J233$OR=as.numeric(J233$OR)
J233$`95..CI..high`=as.numeric(J233$`95..CI..high`)
J233$`95..CI..low`=as.numeric(J233$`95..CI..low`)
J233$Faktor=as.factor(J233$Faktor)
J233$Grupp=as.factor(J233$Grupp)
J233$Faktor=factor(J233$Faktor,levels(J233$Faktor)[order(c(2,1,3,4))])
J233$Grupp=factor(J233$Grupp,levels(J233$Grupp)[order(c(5,3,6,2,4,1))])
#joonis
ggplot(J233,aes(x=Grupp,y=OR))+
geom_point(aes(col=Grupp),cex=3)+
facet_grid(~Faktor,labeller = label_wrap_gen(15))+
geom_errorbar(aes(x=Grupp, ymin=`95..CI..low`,ymax=`95..CI..high`, col=Grupp),width=0.2,linewidth=0.9)+
geom_abline(intercept=1,slope=0)+
theme_minimal()+
theme(legend.title=element_blank())+
ylab("Ĺ ansisuhe (OR) ja 95% usaldusvahemik")+
xlab("")+
scale_y_continuous(limits=c(0.75,1.75))+
theme(axis.text.x = element_text(angle = 90),legend.position = "none")+
scale_color_manual(values=c("#FF3600","#6666cc","#668080","#668080","#668080","#668080"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
theme(strip.text.y = element_text(angle = 360,color="#668080"),strip.text.x=element_text(color="#668080"))
