Learn R Programming

imageData (version 0.1-21)

probeDF: Compares, for a set of specified values of df, a response and the smooths of it, possibly along with growth rates calculated from the smooths

Description

Takes a response and, for each individual, uses smooth.spline to smooth its values for each of the degrees of freedom values in df. Provided get.rates is TRUE, both the Absolute Growth Rates (AGR) and the Relative Growth Rates (RGR) are calculated for each smooth, either using differences or first derivatives. A combination of the unsmoothed and smoothed values, as well as the AGR and RGR, can be plotted for each value in df. Note that the arguments that modify the plots apply to all plots that are produced.

Usage

probeDF(data, response = "Area", xname="xDays", individuals="Snapshot.ID.Tag", na.rm = FALSE, df, get.rates = TRUE, rates.method="differences", times.factor = "Days", x = NULL, facet.x = "Treatment.1", facet.y =  "Smarthouse", which.plots = c("smoothed", "AGR", "RGR"), ggplotFuncs = NULL, ...)

Arguments

data
A data.frame containing the data.
response
A character specifying the response variable to be supplied to smooth.spline and that is to be plotted on the y-axis.
xname
A character giving the name of the numeric that contains the values of the predictor variable to be supplied to smooth.spline.
individuals
A character giving the name(s) of the factor(s) that define the subsets of the data for which each subset corresponds to the response values for an individual.
na.rm
A logical indicating whether or not rows of data with NAs are to be removed prior to smoothing.
df
A numeric specifying the set of degrees of freedom to be probed.
get.rates
A logical specifying whether or not the growth rates (AGR and RGR) are to be computed and stored.
rates.method
A character specifying the method to use in calculating the growth rates. The two possibilities are "differences" and "derivates".
times.factor
A character giving the name of the column in data containing the factor for times at which the data was collected. Its levels will be used in calculating growth rates and should be numeric values stored as characters.
x
A character giving the variable to be plotted on the x-axis. If x is NULL then xname is used.
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.
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.
which.plots
A character giving the plots that are to be produced. If none, no plots are produced. If all, plots of the unsmoothed response and, for each value of df, plots of the smoothed response, the AGR and RGR are produced. If responseComparison, a combined plot of the unsmoothed response and the smoothed response is produced for for each value of df.
ggplotFuncs
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. Note that these functions are applied to all three plots produced.
...
allows passing of arguments to longiPlot.

Value

data.frame containing individuals, times.factor, facet.x, facet.y, xname, response, and, for each df, the smoothed response, the AGR and the RGR. It is returned invisibly. The names of the new data are constructed by joining elements separated by full stops (.). In all cases, the last element is the value of df. For the smoothed response, the other elements are response and "smooth"; for AGR and RGR, the other elements are the name of the smoothed response and either "AGR" or "RGR".

See Also

splitSplines, splitContGRdiff, smooth.spline, ggplot.

Examples

Run this code
data(exampleData)
vline <- list(ggplot2::geom_vline(xintercept=20, linetype="longdash", size=1),
              ggplot2::scale_x_continuous(breaks=seq(12, 36, by=2)))
probeDF(data = longi.dat, response = "Area", df = c(4,7), x="xDays+24.16666667", 
        ggplotFuncs=vline)

Run the code above in your browser using DataLab