# Create sample data
set.seed(1023)
sample_data <- round(data.frame(year = 1997:2021,
time_data1 = 1:25 + rnorm(25),
time_data2 = 30:6 + runif(25, 0, 10),
time_data3 = rnorm(25, 5, 5)))
# Plot a graph with time_data1
plot(sample_data$year,
sample_data$time_data1,
type = "l",
col = 2,
ylim = c(- 15, 40),
xlab = "Year",
ylab = "Values")
# Add line graphs of other two dataset
lines(sample_data$year,
sample_data$time_data2,
type = "l",
col = 3)
lines(sample_data$year,
sample_data$time_data3,
type = "l",
col = 4)
# Add legend in top right corner
legend("topright",
c("Geeksforgeeks", "technical-scripter", "geek-i-knack"),
lty = 1,
col = 2:4)