View source: R/panel.meanspag.r
panel.meanspag | R Documentation |
Lattice panel function for spagghetti plots with a mean line
panel.meanspag(
x,
y,
subscripts,
groups,
...,
myFun = mean,
sumText = "Mean",
individual.col = gray[5],
type = "l",
average.lwd = 3,
average.col = red[8],
add.legend = TRUE,
legend.panel.row,
legend.panel.column,
legend.x,
legend.y,
show.points = FALSE
)
x, y |
The regular x, y input for panel functions |
subscripts |
default lattice pass-through |
groups |
default lattice pass-through |
... |
passed to panel.superpose() |
myFun |
the summarization function (mean) |
sumText |
text to describe the summary function ("mean") |
individual.col |
= color of individual lines (spagghetti elements) |
type |
like the lattice argument type for line type |
average.lwd |
line width of average line |
average.col |
color of average line |
add.legend |
logical (T) determining if a legend should be drawn |
legend.panel.row |
row number of the legend in the x by x grid of panels |
legend.panel.column |
column number of the legend in the x by x grid of panels |
legend.x |
x coordinate within the panel |
legend.y |
y coordinate within the panel |
show.points |
logical indicating to show observed data dots |
Lattice panel output (invisible)
## Not run:
library(lattice)
pkpdData = example.pkpdData()
xyplot(value ~ time | dose * type
, data = pkpdData
, subset = dose > 0 & value > 0
, groups = id
, aspect = 1
, panel = panel.meanspag
)
out = get.xpose.tables(path = file.path(getOption("qpExampleDir")), run = "example2")
trellis.strip.color()
xyplot(CONC ~ TIME
, data = out
, groups = ID
, subset = EVID == 0
, aspect = 1
, scales = list(x = list(relation = "free"), y = list(log = 10))
, panel = panel.meanspag
, yscale.components = yscale.components.log10.3
)
# in case there are too many times to average by then the following might be #'#better interpretable
ptimes = seq(min(out$TIME),max(out$TIME), length = 14)
xyplot(CONC ~ Hmisc::Cbind(TIME, metrumrg::snap(TIME, rule = ptimes))
, data = out
, groups = ID
, subset = EVID == 0
, aspect = 1
, scales = list(x = list(relation = "free"), y = list(log = 10))
, panel = function(x,y,...)
{
panel.xyplot(x,y,..., col = gray[5], type = 'l')
yy = tapply(y, attr(x, "other")[,1], mean)
llines(as.numeric(names(yy)), yy, col = red[8], lwd = 2)
}
, yscale.components = yscale.components.log10.3
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.