Restrict fitted regression line (abline) to range of data used in model
问题 Is it possible to draw an abline of a fit only in a certain range of x-values? I have a dataset with a linear fit of a subset of that dataset: # The dataset: daten <- data.frame(x = c(0:6), y = c(0.3, 0.1, 0.9, 3.1, 5, 4.9, 6.2)) # make a linear fit for the datapoints 3, 4, 5 daten_fit <- lm(formula = y~x, data = daten, subset = 3:5) When I plot the data and draw a regression line: plot (y ~ x, data = daten) abline(reg = daten_fit) The line is drawn for the full range of x-values in the