plotMedianDeviations {growthPheno}R Documentation

Calculates and plots the median of the deviations of the smoothed values from the observed values.

Description

Calculates and plots the median of the deviations of the supplied smoothed values from the supplied observed values for traits and combinations of different smoothing methods and smoothing degrees of freedom, possibly for subsets of factor combinations. The requisite values can be generated using probeSmoothing with which.plots set to none. The results of smoothing methods applied externally to growthPheno can be included via the extra.smooths argument. Envelopes of the median value of a trait for each factor combination can be added.

Note: this function is soft deprecated and may be removed in future versions.
Use plotSmoothsMedianDevns.

Usage

plotMedianDeviations(data, response, response.smoothed, 
                     x = NULL, xname="xDays", 
                     individuals = "Snapshot.ID.Tag",  
                     x.title = NULL, y.titles = NULL,
                     facet.x = "Treatment.1", facet.y = "Smarthouse", 
                     labeller = NULL, 
                     trait.types = c("response", "AGR", "RGR"), 
                     propn.types = c(0.1, 0.5, 0.75), propn.note = TRUE, 
                     alpha.med.devn = 0.5, 
                     smoothing.methods = "direct", df, extra.smooths = NULL, 
                     ggplotFuncsMedDevn = NULL, printPlot = TRUE, ...)

Arguments

data

A data.frame containing the observed and smoothed values from which the deviations are to be computed. There should be a column of smoothed values for each combination of smoothing.methods, df and the types specified by trait.types. In addition, there should be a column of values for each element of extra.smooths in combination with the elements of trait.types. Also, there should be a column of observed values for each of the types specified by trait.types

. The naming of the columns for smoothed traits should follow the convention that a name is made up, in the order sepcified, of (i) a response.smoothed, (ii) the trait.type if not just a response trait type, a smoothing.method or an extra.smooths and, (iii) if a smoothing.method, a df. Each component should be separated by a period (.).

response

A character specifying the response variable for which the observed values are supplied. Depending on the setting of trait.types, the observed values of related trait.types may also need to be be supplied.

response.smoothed

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 .smooth is added. Depending on the setting of trait.types, the smoothed values of related trait.types may also need to be be supplied.

x

A character giving the variable to be plotted on the x-axis; it may incorporate an expression. If x is NULL then xname is used.

xname

A character giving the name of the numeric that contains the values from which x is derived, it being that x may incorporate an expression.

individuals

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).

x.title

A character giving the title for the x-axis. If NULL then set to xname.

y.titles

A character giving the titles for the y-axis, one for each trait specified by trait.types. If NULL then set to the traits derived for response from trait.types.

facet.x

A data.frame giving the variable to be used to form subsets to be plotted in separate columns of plots. Use "." if a split into columns is not wanted. For which.plots set to methodcompare or dfcompare facet.x is ignored.

facet.y

A data.frame giving the variable to be used to form subsets to be plotted in separate rows of plots. Use "." if a split into columns is not wanted.

labeller

A ggplot function for labelling the facets of a plot produced using the ggplot function. For more information see ggplot.

trait.types

A character giving the traits types that are to be plotted. While AGR and RGR are commonly used, the names can be arbitrary, except that response is a special case that indicates that the original response is to be plotted.

propn.types

A numeric giving the proportion of the medians values of each of the trait.types that are to be plotted in the median deviations plots. If set to NULL, the plots of the proprotions are omitted.

propn.note

A logical indicating whether a note giving the proportion of the median values plotted in the compare.medians plots.

alpha.med.devn

A numeric specifying the degrees of transparency to be used in plotting a median deviations plot. It is a ratio in which the denominator specifies the number of points (or lines) that must be overplotted to give a solid cover.

smoothing.methods

A character giving the smoothing method used in producing the response.smoothed and which is to be used in labelling the plot.

df

A numeric specifying the smoothing degrees of freedom used in producing the response.smoothed and which is to be used in labelling the plot.

extra.smooths

A character specifying one or more smoothing.method labels that have been used in naming of columns of smooths of the response obtained by methods other than the smoothing spline methods provided by growthPheno. Depending on the setting of trait.types, the smoothed values of related trait types must also be supplied, with names constructed according to the convention described under data.

ggplotFuncsMedDevn

A list, each element of which contains the results of evaluating a ggplot function. It is created by calling the list function with a ggplot function call for each element. These functions are applied in creating the ggplot object.

printPlot

A logical indicating whether or not to print any plots.

...

allows passing of arguments to plotLongitudinal.

Value

A list that consists of two components: (i) a componenent named plots that stores a list of the median deviations plots, one for each trait.types; (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.

Author(s)

Chris Brien

See Also

plotDeviationsBoxes, probeSmoothing, ggplot.

Examples

data(exampleData)
vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1),
              ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)))
traits <- probeSmoothing(data = longi.dat, xname = "xDAP", times.factor = "DAP", 
                         response = "PSA", response.smoothed = "sPSA", 
                         df = c(4:7), 
                         facet.x = ".", facet.y = ".",
                         which.plots = "none",
                         propn.types = NULL)
med <- plotMedianDeviations(data = traits, 
                            response = "PSA", response.smoothed = "sPSA", 
                            x="xDAP", xname = "xDAP", 
                            df = c(4,7), x.title = "DAP", 
                            facet.x = ".", facet.y = ".",
                            trait.types = "response", propn.types = 0.05,
                            ggplotFuncsMedDevn = vline)

[Package growthPheno version 2.1.25 Index]