library(ggplot2)
library(tidyr)
library(tibble)
#faili sisselugemine ja andmete formaadi korrigeerimine
J332=read.csv("PT3-T3.3-J3.3.2.csv",header=TRUE, encoding ="UTF-8")[1:6,]
names(J332)=c("Faktor","4. klass","8. klass","11. klass","Täiskasvanute gümnaasium")
J332=pivot_longer(J332,2:5)
J332$Faktor=as.factor(J332$Faktor)
J332$name=as.factor(J332$name)
J332$name=factor(J332$name,levels(J332$name)[order(c(2,4,3,1))])
J332$Faktor=factor(J332$Faktor,levels(J332$Faktor)[order(c(5,4,6,2,1,3))])
#joonis
ggplot(J332)+
geom_col(aes(x=Faktor,y=value,fill=name),pos=position_dodge(0.8),width=0.7)+
theme_minimal()+
theme(legend.position = "bottom")+
coord_flip()+
scale_fill_manual(values=c("#81DBFE","#F25D23","#38bf7b","#6666cc"),breaks=c("4. klass","8. klass","11. klass","Täiskasvanute gümnaasium"))+
theme(strip.text.x=element_text(color="#668080"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
scale_y_continuous(limits=c(0,4),breaks=c(0,1,2,3,4))+
theme(legend.title = element_blank())+
ylab("")+
xlab("")
## Warning: Removed 1 rows containing missing values (`geom_col()`).
