library(tidyr)
library(ggplot2)
#faili sisselugemine ja andmete formaadi korrigeerimine
J116=read.csv("PT1-T1.1-J1.1.6.csv",header=TRUE, encoding ="UTF-8")
J116=na.omit(J116)
names(J116)[2:10]=c("2004","2006","2008","2010","2012","2014","2016","2018","2021")
J116=pivot_longer(J116,col=names(J116[,2:10]),"Year")
J116$Year=as.numeric(J116$Year)

#joonis
ggplot(J116)+
  geom_line(aes(x=Year,y=value,col=Answer),linewidth=1.5)+
  scale_color_manual(values=c("#6666CC","#FF3600","#8FA300"),breaks=c("Good","Satisfactory
","Bad"))+ #siin ei ole funktsioon mitte fill vaid color, kuna joonobjektid. 
  ylab("% of people at least somewhat satisfied with life")+
  scale_x_continuous(breaks=(unique(J116$Year)))+
  scale_y_continuous(breaks=c(0,25,50,75,100),limits=c(0,100))+
  theme_minimal()+
  theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
  labs(col = "Self-assessment of health")