plotSmoothsMedianDevns | R Documentation |
data.frame
in long format.Calculates and plots the medians of the deviations of the supplied smoothed values from the
supplied observed values for traits and combinations of different smoothing parameters,
possibly for subsets of non-smoothing-factor
combinations. The observed and smoothed values are supplied in
long format i.e. with the values for each set of smoothing parameters stacked one under the other
in the supplied data.frame
. Such data can be generated using probeSmooths
;
to prevent probeSmooths
producing the plots, which it is does using
plotSmoothsComparison
, plotDeviationsBoxes
and
plotSmoothsMedianDevns
, set which.plots
to none
.
The smoothing parameters include spline.types
, df
, lambdas
and
smoothing.methods
(see probeSmooths
).
Multiple plots, possibly each having multiple facets, are produced using ggplot2
.
The layout of these plots is controlled via the smoothing-parameter factor
s
Type
, Tuning
(the combination of TunePar
and TuneVal
) and
Method
that can be supplied to the arguments plots.by
,
plots.group
, facet.x
and facet.y
. These plots
and
facet
arguments can also include factor
s other than the
smoothing-parameter factor
s, that are also associated with the data.
The basic principle is that the number of levels combinations of the smoothing-parameter
factor
s included in the plots
and facet
arguments must be the same as those covered by the combinations of the values supplied to
spline.types
, df
, lambdas
and Method
and incorporated into the
smooths.frame
input to plotSmoothsMedianDevns
via the data
argument.
This ensures that smooths from different parameter sets are not pooled in a single plot.
Envelopes of the median value of a trait for each factor
combination can be added.
plotSmoothsMedianDevns(data, response, response.smoothed = NULL,
individuals = "Snapshot.ID.Tag", times = "DAP",
trait.types = c("response", "AGR", "RGR"),
x.title = NULL, y.titles = NULL,
meddevn.plot.args =
args4meddevn_plot(plots.by = NULL, plots.group = NULL,
facet.x = ".", facet.y = ".",
propn.note = TRUE,
propn.types = c(0.1, 0.5, 0.75)),
printPlot = TRUE, ...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
trait.types |
A |
x.title |
Title for the x-axis. If |
y.titles |
A |
meddevn.plot.args |
A named |
printPlot |
A |
... |
allows passing of arguments to other functions; not used at present. |
A list
that consists of two components: (i) a componenent named
plots
that stores a two-level list
of the median deviations
plots; the first-level list
has a component for each
trait.types
and each of these list
(s) is a second-level
list
that contains the set of plots specified by plots.by
(if plots.by
is NULL
, a single plot is stored); (ii) a component named
med.dev.dat
that stores the data.frame
containing the
median deviations that have been plotted. Each plot in the plots
list
is in an object of class ggplot
, which can be
plotted using print
.
Chris Brien
traitSmooth
, probeSmooths
, args4meddevn_plot
, plotSmoothsComparison
, plotDeviationsBoxes
, ggplot
.
data(exampleData)
vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1))
traits <- probeSmooths(data = longi.dat,
response = "PSA", response.smoothed = "sPSA",
times = "DAP",
get.rates = FALSE, trait.types = "response",
smoothing.args =
args4smoothing(smoothing.methods = "direct",
spline.types = "NCSS",
df = c(4,7), lambdas = NULL),
which.plots = "none")
med <- plotSmoothsMedianDevns(data = traits,
response = "PSA", response.smoothed = "sPSA",
times = "DAP", trait.types = "response",
meddevn.plot.args =
args4meddevn_plot(plots.by = NULL,
plots.group = "Tuning",
facet.x = ".", facet.y = ".",
propn.types = 0.02,
ggplotFuncs = vline))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.