Вы должны явно добавить аргумент label
в text
, как показано ниже:
# Train data.frame simulation
set.seed(123)
year = seq(2017, 2019.5, length.out = 20)
Sales = seq(75, 200, length.out = 20)
train <- data.frame(year, Sales)
# Source data simulation
year = seq(2017, 2019.5, length.out = 10)
Sales_source = seq(75, 200, length.out = 10) + rnorm(10) * 10
e <- data.frame(year, Sales_source)
# plotting
par(mfrow = c(1,1))
plot(train, type="l", xlim = c(2017, 2019.5),
ylim = c(75, 200), xlab = "Year", ylab = "Sales")
title(main = "13 Month Sales Forecast")
lines(e, col = "green")
points(train, pch = 19)
points(e, col = "green", pch = 19)
# Adding labels
text(e, labels = ceiling(Sales_source), pos = 2)