growthPheno (version 1.0-13)

plotLongitudinal: Plots longitudinal data for a set of indiividuals

Description

Produce profile or longitudinal plots of a response using ggplot. A line is drawn for the data for each individual and the plot can be facetted 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).

Warning: longiPlot will be deprecated in future versions, its synonym plotLongitudinal being preferred.

Usage

plotLongitudinal(data, x = "xDays+44.5", response = "Area", 
                 individuals = "Snapshot.ID.Tag", title = NULL, 
                 x.title = "Days", y.title = "Area (kpixels)", 
                 facet.x = "Treatment.1", facet.y = "Smarthouse", 
                 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(s) of the factor(s) that define the subsets of the data for which each subset corresponds to the response values for an individual.

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

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.

printPlot

A logical indicating whether or not to print the plot.

Value

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

See Also

ggplot, labeller.

Examples

Run this code
# NOT RUN {
data(exampleData)
plotLongitudinal(data = longi.dat, response = "Area.smooth")

plt <- plotLongitudinal(data = longi.dat, response = "Area.smooth", x.title = "DAP",  
                        y.title = "Area.smooth", x="xDays+35.42857143", 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, response = "Area.smooth", x.title = "DAP",  
                 y.title = "Area.smooth", x="xDays+35.42857143", 
                 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))))
# }

Run the code above in your browser using DataCamp Workspace