J.doe - 7 months ago 85

R Question

Answer

Oh, @GBR24 has nice formatted data. Then I'm going to elaborate a little bit based on my comment.

```
fit <- lm(y ~ poly(x, 3)) ## polynomial of degree 3
plot(x, y) ## scatter plot (colour: black)
x0 <- seq(min(x), max(x), length = 20) ## prediction grid
y0 <- predict.lm(fit, newdata = list(x = x0)) ## predicted values
lines(x0, y0, col = 2) ## add regression curve (colour: red)
```