---
output: html_document
editor_options: 
  chunk_output_type: console
---




<br><br> 


## Delta convergence 


Delta convergence is a reduction of a country distance from the best performing Member State. There is convergence if there is a decrease in the period considered. 

<br><br> 
<img src="delta_convergence.png">
<br>

For each year, the above summaries are calculated to assess if a reduction in 
the amplitude on the took place.
<br> <br>
<img src="eurofound.jpg" width=50px height=40px>
<br>
```{r,echo = FALSE,fig.width=6}
## already set at start
resDelta <-   delta_conv(wkDF2,
                         timeName = timeName,
                         indiType = params$indiType,# "highBest","lowBest", #params$indiType
                         time_0 = NA,
                         time_t = NA,
                         extended = TRUE) 


lastRowAveragesDel <- nrow(resDelta$res$delta_conv)
 
plot2de <- qplot( resDelta$res$delta_conv$time, resDelta$res$delta_conv$delta,
      xlab= paste("Years "),
      ylab= paste("Delta  (",aggregation,")")) +
  geom_line()  +
  ggplot2::scale_x_continuous(
       breaks = seq(ptime_0,ptime_t),
       labels = seq(ptime_0,ptime_t)) +
  ggplot2::theme( 
         axis.text.x=ggplot2::element_text(
         angle = 45,
         vjust = 1,
         hjust = 1))

delta_gr1 <-  grid.arrange(
                    plot2de, ncol=1)
# export
out_packed_list$delta_gr1 <-  delta_gr1

invisible(delta_gr1) 

```


  
<br>


Delta summary list:   


  * Indicator type: `r params$indiType`    
<br>  
  * Change in average:    
  
      + Year `r ptime_0`, average:  `r as.numeric(outMed[1,aggregation])`   
      + Year `r ptime_t`, average:  `r as.numeric(outMed[lastRowAverages,aggregation])`     
      + Difference $\Delta$ between years: `r as.numeric(outMed[lastRowAverages,aggregation])-as.numeric(outMed[1,aggregation])`     
<br>
  * Change in delta values:    
  
      + Year `r ptime_0`, delta:  `r as.numeric(resDelta$res$delta_conv[1,'delta'])`   
      + Year `r ptime_t`, delta:  `r as.numeric(resDelta$res$delta_conv[lastRowAveragesDel,'delta'])`     
      + Difference  between years: `r resDelta$res$diffe_delta`    
      +  **Overall: `r resDelta$res$label_strict`  `r resDelta$res$label_conver`** 
  
             
      
 
 
 
 
```{r,echo=FALSE,eval=semaforo[['delta']]}

out_packed_list$deltaSummary <-  list(
  indicatorType= params$indiType,
  startingYear = ptime_0,
  endingYear = ptime_t,
  startingAverage = as.numeric(outMed[1,aggregation]),
  endingAverage = as.numeric(outMed[lastRowAverages,aggregation]),
  DeltaAverage =  as.numeric(outMed[lastRowAverages,aggregation])-
                   as.numeric(outMed[1,aggregation]),
  #
  delta_conv_output= resDelta$res

  )
```


 




