[R] adding regression curve to xyplot

Carlisle Thacker Carlisle.Thacker at noaa.gov
Tue Nov 30 17:59:28 CET 2004

The axes are switched in xyplot.  Oceanographers like to have temperature
as the vertical axis and salinity horizontal.  But temperature is used to
predict salinity.  Confusing, and makes everything complicated.

So panel.abline(thislm) would give the wrong line, as would
type=c("p","r").  And neither would handle a parabolic fit.

The problem was my using t rather than y when getting news.

Thanks for all the help.

Deepayan Sarkar wrote:
> On Tuesday 30 November 2004 10:24, Prof Brian Ripley wrote:
>>On Tue, 30 Nov 2004, Carlisle Thacker wrote:
>>>Dear R-listers,
>>>It seems that predict() behaves differently within panel.xyplot. 
>>>Am I doing something stupid?
>>You fitted the model lm(x ~ y) and supplied new values for t, not y.
>>Using panel.abline would be a bit easier: just call
>>panel.abline(thislm) from your panel function.
> That wouldn't quite work, since the response and predictor are switched 
> in the lm fit.
> Deepayan

More information about the R-help mailing list