library(ggplot2)
library(tidyr)
#faili sisselugemine ja andmete formaadi korrigeerimine
J01=read.csv2("PT0-J0.1.csv",header=TRUE, encoding ="UTF-8")
J01$Sugu[J01$Sugu=="(mehed)"]="Mehed"
J01$Sugu[J01$Sugu=="(naised)"]="Naised"
names(J01)[4:16]=as.character(c(2009:2021))
J01=pivot_longer(J01,4:16)
J01$value=as.numeric(J01$value)
J01$Faktor=paste(J01$Faktor,J01$Sugu,sep=".\n ")
ggplot(J01)+
geom_line(aes(x=name,y=value,col=Faktor,group=Faktor),linewidth=1)+
facet_wrap(~Riik,nrow=2)+
theme_minimal()+
scale_color_manual(values=c("#6666cc","#FF3600","#8FA300","#f09d00"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
theme(strip.text.x=element_text(face="bold",color="#668080"))+
xlab("")+
ylab("Vanus aastates")+
#guides(color = guide_legend(nrow=2,byrow = TRUE)) +
theme(legend.title = element_blank(),legend.position = "bottom")
## Warning: Removed 2 rows containing missing values (`geom_line()`).
