[R] Plot nls line on plot?

Christian Ritz
Fri, 09 Oct 2009 06:00:26 -0000

Hi Doug,

you can add the fitted curve using the following general paradigm:

## Plotting the data
plot(p~z)


## Defining grid of z values
## (100 values ensures a smooth curve in your case)
zValues <- seq(min(z), max(z), length.out = 100)


## Adding predicted values corresponding to the grid values
lines(zVal, predict(fit, data.frame(z = zValues)))



Christian