[R] Plot nls line on plot?

Christian Ritz ritz at life.ku.dk
Fri Oct 9 08:00:26 CEST 2009

Hi Doug,

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

## Plotting the data

## 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)))


More information about the R-help mailing list