[R] trellis graph question
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Mar 29 05:35:42 CEST 2006
On 3/28/06, Greg Tarpinian <sasprog474474 at yahoo.com> wrote:
> R2.2, WinXP:
>
> I am using xyplot( ) to generate time plots of plasma concentration data.
> The following is an edited version of my code:
>
> xyplot(log.conc ~ time| group, data = foo,
> groups = subject,
> panel = function(x, y, panel.number, ...)
> {
> panel.superpose(x, y,
> subscripts = TRUE,
> groups = foo$group,
> type = 'l', col = "black")
> panel.loess(x,y,span = .66, col = "red", lwd = 3)
> panel.grid(h=-1, v=-1, lwd = 1)
> }
> )
>
> For each dose group, I want to plot all subjects within the group and
> superimpose a loess smoother so that an overall trend can be made
> apparent. The code above does this, but has the annoying tendency to
> "connect" the first-last points for (say) subject 1 with the last-first
> points of (say) subject 2.....
>
> This annoyance is something that is tolerable for exploratory graphs
> but not for publication-quality graphs... Is there a "fix" to this
> "connect-the-wrong-points" problem?
I'm confused by your panel function, but from your description, the
following should do what you want:
xyplot(log.conc ~ time| group, data = foo,
groups = subject,
panel = function(..., type, col, lwd, span)
{
panel.grid(h=-1, v=-1, lwd = 1)
panel.superpose(..., type = 'l', col = "black", lwd = 1)
panel.loess(..., span = .66, col = "red", lwd = 3)
})
Deepayan
More information about the R-help
mailing list