plotSmoothsComparison | R Documentation |
Plots the smoothed values for an observed response
and, optionally, the unsmoothed
observed response
using plotProfiles
. Depending on the setting of
trait.types
(response
, AGR
or RGR
), the computed traits of the
Absolute Growth Rates (AGR) and/or the Relative Growth Rates (RGR) are plotted. This
function will also calculate and produce, using plotDeviationsBoxes
, boxplots
of the deviations of the supplied smoothed values from the observed response values for the
traits and for combinations of the different smoothing parameters and 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 smooths.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 arguments plots.by
,
facet.x
and facet.y
. The basic principle is that the number of levels
combinations of the smoothing-parameter factor
s Type
, TunePar
,
TuneVal
, Tuning
(the combination of (TunePar
and TuneVal
), and
Method
that are included in plots.by
, facet.x
and
facet.y
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 plotSmoothsComparison
via the
data
argument. This ensures that smooths from different parameter sets are not
pooled into the same plot. The factor
s other than the smoothing-parameter
factor
s can be supplied to the plots.by
and facet
arguments.
The following profiles plots can be produced: (i) separate plots of the
smoothed traits for each combination of the smoothing parameters
(include Type
, Tuning
and Method
in plots.by
);
(ii) as for (i), with the corresponding plot for the unsmoothed trait
preceeding the plots for the smoothed trait (also set include.raw
to
alone
); (iii) profiles plots that compare a smoothed trait for all
combinations of the values of the smoothing parameters, arranging the plots
side-by-side or one above the other (include Type
, Tuning
and
Method
in facet.x
and/or facet.y
- to include the
unsmoothed trait set include.raw
to one of facet.x
or
facet.y
; (iv) as for (iii), except that separate plots are
produced for each combination of the levels of the factor
s
in plot.by
and each plot compares the smoothed traits for the
smoothing-parameter factor
s included in facet.x
and/or facet.y
(set both plots.by
and one or more of
facet.x
and facet.y
).
plotSmoothsComparison(data, response, response.smoothed = NULL,
individuals = "Snapshot.ID.Tag", times = "DAP",
trait.types = c("response", "AGR", "RGR"),
x.title = NULL, y.titles = NULL,
profile.plot.args =
args4profile_plot(plots.by = NULL,
facet.x = ".", facet.y = ".",
include.raw = "no"),
printPlot = TRUE, ...)
data |
A |
response |
A |
response.smoothed |
A |
times |
A |
individuals |
A |
trait.types |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
profile.plot.args |
A named |
printPlot |
A |
... |
allows passing of arguments to |
A multilevel list
that contains the ggplot
objects for the plots produced. The first-level list
has a component for each trait.types
and each of these is a
second-level list
that contains the trait
profile plots and for a trait
. It may contain components labelled
Unsmoothed
, all
or for one of the levels of the
factor
s in plots.by
; each of these third-level
ist
s contains a ggplot
object that can
be plotted using print
.
Chris Brien
traitSmooth
, probeSmooths
, args4profile_plot
, plotDeviationsBoxes
, plotSmoothsMedianDevns
, ggplot2
.
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",
#only df is changed from the probeSmooth default
smoothing.args =
args4smoothing(smoothing.methods = "direct",
spline.types = "NCSS",
df = c(4,7), lambdas = NULL),
which.plots = "none")
plotSmoothsComparison(data = traits,
response = "PSA", response.smoothed = "sPSA",
times = "DAP", x.title = "DAP",
#only facet.x is changed from the probeSmooth default
profile.plot.args =
args4profile_plot(plots.by = NULL,
facet.x = "Tuning", facet.y = ".",
include.raw = "no",
ggplotFuncs = vline))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.