[R] multiple lowess line in one plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Jan 4 22:39:26 CET 2006


On 1/4/06, Gregory Snow <Greg.Snow at intermountainmail.org> wrote:
> Here is one approach using lattice (trellis) graphics:
>
> tmp.state <- data.frame( Frost=state.x77[,'Frost'],
> 	Murder=state.x77[,'Murder'],
> 	Region=state.region)
>
> library(lattice)
> trellis.par.set(col.whitebg())
> xyplot( Murder ~ Frost, groups=Region, data=tmp.state,
> 	panel.groups=function(...){panel.loess(...);panel.xyplot(...)}
> ,span=.8)

which can be shortened to

xyplot(Murder ~ Frost, groups=Region, data=tmp.state,
       type = c('p', 'smooth'), span = .8)

-Deepayan




More information about the R-help mailing list