Plot fitted line within certain range R

前端 未结 5 2240
执笔经年
执笔经年 2020-12-31 05:26

Using R, I would like to plot a linear relationship between two variables, but I would like the fitted line to be present only within the range of the data.

For exam

5条回答
  •  半阙折子戏
    2020-12-31 05:41

    In addition to using predict with lines or segments you can also use the clip function with abline:

    x <- 1:10
    y <- 1:10
    plot(x,y)
    clip(1,10, -100, 100)
    abline(lm(y~x))
    

提交回复
热议问题