plotLongitudinal: Produces profile plots of longitudinal data for a set of...

plotLongitudinalR Documentation

Produces profile plots of longitudinal data for a set of individuals

Description

Produce profile plots of longitudinal data for a response using ggplot. A line is drawn for the data for each individual and the plot can be faceted so that a grid of plots is produced. For each facet a line for the medians over time can be added, along with the vaue of the outer whiskers (median +/- 1.5 * IQR).

Usage

plotLongitudinal(data, x = "xDays+44.5", response = "Area", 
                 individuals = "Snapshot.ID.Tag", title = NULL, 
                 x.title = "Days", y.title = "Area (kpixels)", 
                 facet.x = ".", facet.y = ".", 
                 labeller = NULL, colour = "black", 
                 colour.column = NULL, colour.values = NULL, 
                 alpha = 0.1, addMediansWhiskers = FALSE, 
                 xname = "xDays", ggplotFuncs = NULL, 
                 printPlot = TRUE)

Arguments

data

A data.frame containing the data to be plotted.

x

A character giving the variable to be plotted on the x-axis.

response

A character specifying the response variable that is to be plotted on the y-axis.

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

Title for the x-axis.

y.title

Title for the y-axis.

title

Title for the plot.

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 rows is not wanted.

labeller

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

colour

A character specifying a single colour to use in drawing the lines for the profiles. If colouring according to the values of a variable is required then use colour.column.

colour.column

A character giving the name of a column in data over whose values the colours of the lines are to be varied. The colours can be specified using colour.values.

colour.values

A character vector specifying the values of the colours to use in drawing the lines for the profiles. If this is a named vector, then the values will be matched based on the names. If unnamed, values will be matched in order (usually alphabetical) with the limits of the scale.

alpha

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

addMediansWhiskers

A logical indicating whether plots over time of the medians and outer whiskers are to be added to the plot. The outer whiskers are related to the whiskers on a box-and-whisker and are defined as the median plus (and minus) 1.5 times the interquartile range (IQR). Points lying outside the whiskers are considered to be potential outliers.

xname

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

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. These functions are applied in creating the ggplot object.

printPlot

A logical indicating whether or not to print the plot.

Value

An object of class "ggplot", which can be plotted using print.

Author(s)

Chris Brien

See Also

ggplot, labeller.

Examples

data(exampleData)
plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA")

plt <- plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA", 
                        x.title = "DAP",  y.title = "sPSA (kpixels)", 
                        facet.x = "Treatment.1", facet.y = "Smarthouse", 
                        printPlot=FALSE)
plt <- plt + ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1) +
             ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)) + 
             ggplot2::scale_y_continuous(limits=c(0,750))
print(plt)

plotLongitudinal(data = longi.dat, x="xDAP", response = "sPSA", 
                 x.title = "DAP",  y.title = "sPSA (kpixels)", 
                 facet.x = "Treatment.1", facet.y = "Smarthouse", 
                 ggplotFuncs = list(ggplot2::geom_vline(xintercept=29, 
                                                        linetype="longdash", 
                                                        size=1), 
                                    ggplot2::scale_x_continuous(breaks=seq(28, 42, 
                                                                           by=2)), 
                                    ggplot2::scale_y_continuous(limits=c(0,750))))

growthPheno documentation built on Oct. 24, 2023, 5:08 p.m.