library(ggplot2)
library(tidyr)
#faili sisselugemine ja andmete formaadi korrigeerimine
J314=read.csv2("PT3-T3.1-J3.1.4.csv",header=TRUE, encoding ="UTF-8")
J314=pivot_longer(J314, 2:3)
J314$value=as.numeric(J314$value)
J314$Perevorm=as.factor(J314$Perevorm)
J314$Perevorm=factor(J314$Perevorm,levels(J314$Perevorm)[order(c(5,2,4,1,3))])
J314$value=round(J314$value,digits=1)
#joonis
ggplot(J314)+
facet_grid(~name)+
geom_col(aes(x=Perevorm,y=value,fill=name))+
geom_label(aes(x=Perevorm, y=value, label=value))+
theme_minimal()+
theme(legend.position = "none")+
scale_fill_manual(values=c("#4db3d9","#38bf7b"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
theme(strip.text.x=element_text(color="#668080"))+
scale_y_continuous(limits=c(0,10))+
theme(axis.text.x = element_text(angle = 45))+
ylab("Average satisfaction with family life (on a scale of 1–10)")+
xlab("")
