title: trouble in adding labels next to lines in ggplot
body: <p>Here's my code:</p>
  <pre><code>library(&quot;ggplot2&quot;) 
  library(&quot;directlabels&quot;)
  library(&quot;ggrepel&quot;)
  
  gfg_data &lt;- data.frame(x = c(2002, 2003, 2004, 2005, 2006, 
                               2007, 2008, 2009, 2010, 2011, 
                               2012, 2013, 2014, 2015, 2016, 
                               2017,2018, 2019),
                         
                         #Dinamarca/Homens       
                         Dinamarca_H = c( 74.8, 
                                          75.0,
                                          75.4,
                                          76.0,
                                          76.1,
                                          76.2,
                                          76.5,
                                          76.9,
                                          77.2,
                                          77.8,
                                          78.1,
                                          78.3,
                                          78.7,
                                          78.8,
                                          79.0,
                                          79.2,
                                          79.1,
                                          79.5),
                         #Eslováquia/Homens
                         Eslováquia_H = c(69.8,
                                          69.8,
                                          70.3,
                                          70.2,
                                          70.4,
                                          70.6,
                                          70.9,
                                          71.4,
                                          71.8,
                                          72.3,
                                          72.5,
                                          72.9,
                                          73.3,
                                          73.1,
                                          73.8,
                                          73.8,
                                          73.9,
                                          74.3),
                         #Estónia/Homens
                         Estónia_H = c(65.6,
                                       66.4,
                                       66.7,
                                       67.6,
                                       67.6,
                                       67.5,
                                       68.9,
                                       70.0,
                                       70.9,
                                       71.4,
                                       71.4,
                                       72.8,
                                       72.4,
                                       73.2,
                                       73.3,
                                       73.8,
                                       74.0,
                                       74.5),
                         #Dinamarca/Mulheres
                         Dinamarca_M = c(79.4,
                                         79.8,
                                         80.2,
                                         80.5,
                                         80.7,
                                         80.6,
                                         81.0,
                                         81.1,
                                         81.4,
                                         81.9,
                                         82.1,
                                         82.4,
                                         82.8,
                                         82.7,
                                         82.8,
                                         83.1,
                                         82.9,
                                         83.5),
                         #Eslováquia/mulheres
                         Eslováquia_M = c(77.7,
                                          77.7,
                                          78.0,
                                          78.1,
                                          78.4,
                                          78.4,
                                          79.0,
                                          79.1,
                                          79.3,
                                          79.8,
                                          79.9,
                                          80.1,
                                          80.5,
                                          80.2,
                                          80.7,
                                          80.7,
                                          80.8,
                                          81.2),
                         #Estónia/Mulheres
                         Estónia_M = c( 77.2,
                                        77.2,
                                        78.0,
                                        78.2,
                                        78.6,
                                        78.9,
                                        79.5,
                                        80.3,
                                        80.8,
                                        81.3,
                                        81.5,
                                        81.7,
                                        81.9,
                                        82.2,
                                        82.2,
                                        82.6,
                                        82.7,
                                        83.0)
                         
                         
                         
                         
  )
  
  
  
  gfg_plot &lt;- ggplot(gfg_data, aes(x)) +  
    geom_line(aes(y = Dinamarca_H), color = &quot;black&quot;, size = 2) +
    geom_line(aes(y = Eslováquia_H), color = &quot;red&quot;, size = 2) +
    geom_line(aes(y = Estónia_H), color = &quot;green&quot;, size = 2) +
    geom_line(aes(y = Dinamarca_M), color = &quot;blue&quot;, size = 2) +
    geom_line(aes(y = Eslováquia_M), color = &quot;purple&quot;, size = 2) +
    geom_line(aes(y = Estónia_M), color = &quot;yellow&quot;, size = 2) +
    xlab(&quot;ano&quot;) +
    ylab(&quot;esperança média de vida em anos&quot;) 
  geom_label_repel(aes(label = Dinamarca_H ),
                   nudge_x = 1,
                   na.rm = TRUE) 
    geom_label_repel(aes(label = Eslováquia_H ),
                     nudge_x = 1,
                     na.rm = TRUE) 
    geom_label_repel(aes(label = Estónia_H ),
                     nudge_x = 1,
                     na.rm = TRUE) 
    geom_label_repel(aes(label = Dinamarca_M ),
                     nudge_x = 1,
                     na.rm = TRUE) 
    geom_label_repel(aes(label = Eslováquia_M ),
                     nudge_x = 1,
                     na.rm = TRUE) 
    geom_label_repel(aes(label = Estónia_M ),
                     nudge_x = 1,
                     na.rm = TRUE)
  gfg_plot
  </code></pre>
  <p>Which gives this output:</p>
  <p><a href="https://i.stack.imgur.com/M9bFS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M9bFS.jpg" alt="enter image description here" /></a></p>
  <p>I want to add the labels for each line next to them, however nothing happens. I have seen <a href="https://stackoverflow.com/questions/29357612/plot-labels-at-ends-of-lines">Plot labels at ends of lines</a> and <a href="https://statisticsglobe.com/add-labels-at-ends-of-lines-in-ggplot2-line-plot-r" rel="nofollow noreferrer">https://statisticsglobe.com/add-labels-at-ends-of-lines-in-ggplot2-line-plot-r</a> , to no avail.</p>
  <p>A minor problem is that I also want to have every year shown in the x axis, instead of in groups of five.</p>
  <p>Any help?</p>