Here is a simple ggplot chart for two variables:
library("ggplot2")
library("directlabels")
library("tibble")
df <- tibble(
number = 1:10,
var1 = runif(10)*10,
var2 = runif(10)*10
)
ggplot(df, aes(number))+
geom_line(aes(y=var1), color='red')+
geom_line(aes(y=var2), color='blue')
Is it possible to label the last value of var1 and var2 using the expression like that:
direct.label(df, 'last.points')
In my case I get an error:
Error in UseMethod("direct.label") :
no applicable method for 'direct.label' applied to an object of
class