Calculates and produces, 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. Which traits are plotted is controlled by
trait.types
and may include the (response
and the computed traits of the
Absolute Growth Rates (AGR) and/or the Relative Growth Rates (RGR). 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
.
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 incorporated
into the smooths.frame
input to plotSmoothsDevnBoxplots
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.
plotSmoothsDevnBoxplots(data, response, response.smoothed = NULL,
individuals = "Snapshot.ID.Tag", times = "DAP",
trait.types = c("response", "AGR", "RGR"),
which.plots = "absolute.boxplots",
x.title = NULL, y.titles = NULL,
devnboxes.plot.args =
args4devnboxes_plot(plots.by = NULL,
facet.x = ".", facet.y = "."),
printPlot = TRUE, ...)
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
with contains the deviations boxplots
for a response
. Each plot is in an object of class
ggplot
, which can be plotted using print
.
A smooths.frame
, such as is produced by
probeSmooths
and that contains the data resulting from
smoothing a response over time for a set of individuals
, the data
being arranged in long format both with respect to the
times and the smoothing-parameter values used in the smoothing. That is,
each response occupies a single column. The unsmoothed response
and
the response.smoothed
are to be plotted for different sets of values
for the smoothing parameters. The smooths.frame
must include
the columns Type
, TunePar
, TuneVal
, Tuning
and
Method
, and the columns nominated using the arguments
individuals
, times
, plots.by
, facet.x
, facet.y
,
response
, response.smoothed
, and, if requested,
the AGR and the RGR of the response
and response.smoothed
.
The names of the growth rates should be formed from response
and
response.smoothed
by adding .AGR
and .RGR
to both of them.
A character
specifying the response variable for which the
observed values are supplied.
A character
specifying the name of the column
containing the values of the smoothed response variable, corresponding
to response
and obtained for the combinations of
smoothing.methods
and df
, usually using smoothing splines.
If response.smoothed
is NULL
, then
response.smoothed
is set to the response
to which is added
the prefix s
.
A character
giving the name of the column in
data
containing the times at which the data was
collected, either as a numeric
, factor
, or
character
. It will be used to provide the values to be plotted
on the x-axis. If a factor
or character
,
the values should be numerics stored as characters.
A character
giving the name of the
factor
that defines the subsets of the data
for which each subset corresponds to the response
values for
an individual (e.g. plant, pot, cart, plot or unit).
A character
giving the trait.types
that
are to be plotted. If all
, each of response
, AGR
and
RGR
is plotted.
A logical
indicating which plots are to be produced.
The options are either none
or absolute.deviations
and/or
relative.deviations
. Boxplots of the absolute deviations
are specified by absolute.boxplots
, the absolute deviations being
the values of a trait minus their smoothed values (observed - smoothed).
Boxplots of the relative deviations are specified by relative.boxplots
,
the relative deviations being the absolute deviations divided by the
smoothed values of the trait.
Title for the x-axis, used for all plots. If NULL
then set to
times
.
A character
giving the titles for the y-axis,
one for each trait specified by trait.types
and used for all plots.
If NULL
, then set to the traits derived for response
from trait.types
.
A named list
that is most easily
generated using args4devnboxes_plot
, it documenting the
options available for varying the boxplots. Note
that if args4devnboxes_plot
is to be called to change
from the default settings given in the default probeSmooths
call and some of those settings are to be retained, then the arguments
whose settings are to be retained must also be included in the call
to args4devnboxes_plot
; be aware that if you call
args4devnboxes_plot
, then the defaults for this call
are those for args4devnboxes_plot
, NOT the call
to args4devnboxes_plot
shown as the default for
probeSmooths
.
A logical
indicating whether or not to print any
plots.
allows passing of arguments to plotProfiles
.
Chris Brien
traitSmooth
, probeSmooths
, args4profile_plot
, plotDeviationsBoxes
, plotSmoothsMedianDevns
, ggplot
.
data(exampleData)
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")
plotSmoothsDevnBoxplots(data = traits,
response = "PSA", response.smoothed = "sPSA",
times = "DAP", x.title = "DAP",
#only facet.x is changed from the probeSmooth default
devnboxes.plot.args =
args4devnboxes_plot(plots.by = NULL,
facet.x = "Tuning", facet.y = "."))
Run the code above in your browser using DataLab