library(ggplot2)
library(tidyr)
library(scales)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
#faili sisselugemine ja andmete formaadi korrigeerimine
J231=read.csv("PT2-T2.3-J2.3.1.csv",header=TRUE, encoding ="UTF-8")
J231x=J231[1:5,1:17]
J231x=pivot_longer(J231x,2:17)
J231y=J231[8:17,1:17]
J231y[2,1]=J231y[1,1]
J231y[4,1]=J231y[3,1]
J231y[6,1]=J231y[5,1]
J231y[8,1]=J231y[7,1]
J231y[10,1]=J231y[9,1]
J231y$Cl=rep(c("low","high"),5)
J231y=pivot_longer(J231y,2:17)
J231y=pivot_wider(J231y,names_from=Cl,values_from=value)
J231=cbind(J231x,J231y[,3:4])
names(J231)[1:2]=c("Faktor","Year")
J231$Year=sub("X","",J231$Year)
sildid=na.omit(J231)%>%group_by(Faktor)%>%filter(Year%in%c(min(Year),max(Year)))
#joonis
ggplot(J231,aes(x=Year,y=value,col=Faktor))+
geom_line(aes(group=Faktor), linewidth=1.5)+
geom_point(aes(group=Faktor),cex=2)+
geom_label(data=sildid,aes(x=Year,y=value,label=paste(round(value),"%",sep="")),cex=3,show.legend = FALSE)+
theme_minimal()+
theme(legend.title=element_blank())+
theme(legend.position = "bottom")+
ylab("")+
guides(color = guide_legend(nrow=2,byrow = TRUE)) +
scale_color_manual(values=c("#1E272E","#FF3600","#6666cc","#668080","#f09d00"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))
## Warning: Removed 6 rows containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
