plotAnom: Identifies anomalous individuals and produces profile plots...

plotAnomR Documentation

Identifies anomalous individuals and produces profile plots without them and with just them

Description

Uses byIndv4Intvl_ValueCalc and the function anom to identify anomalous individuals in longitudinal data. The user can elect to print the anomalous individuals, a profile plot without the anomalous individuals and/or a profile plot with only the anomalous individuals. The plots are produced using ggplot. The plot can be facettd so that a grid of plots is produced.

Usage

plotAnom(data, response="sPSA", 
         individuals="Snapshot.ID.Tag", 
         times = "DAP", x = NULL, 
         breaks=seq(12, 36, by=2), vertical.line=NULL, 
         groupsFactor=NULL, lower=NULL, upper=NULL, 
         start.time=NULL, end.time=NULL, 
         suffix.interval=NULL, 
         columns.retained=c("Snapshot.ID.Tag", "Smarthouse", "Lane", 
                            "Position", "Treatment.1", "Genotype.ID"),
         whichPrint=c("anomalous","innerPlot","outerPlot"), na.rm=TRUE, ...)

Arguments

data

A data.frame containing the data to be tested and plotted.

response

A character specifying the response variable that is to be tested and 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).

times

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. If not a numeric, it will be converted to a numeric and 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.

x

A character specifying a variable, or a function of variables, to be plotted on the x-axis. If NULL, it will be set to the value of times, which it can be assumed will be converted to a numeric.

breaks

A numeric vector giving the breaks to be plotted on the x-axis scale.

vertical.line

A numeric giving position on the x-axis at which a vertical line is to be drawn. If NULL, no line is drawn.

groupsFactor

A factor giving the name of a factor that defines groups of individuals between which the test for anomalous individuals can be varied by setting values for one or more of lower, upper, start.time and end.time to be NULL, a single value or a set of values whose number equals the number of levels of groupsFactor. If NULL or only a dingle value is supplied, the test is the same for all individuals.

lower

A numeric such that values in response below it are considered to be anomalous. If NULL, there is no testing for values below the lower bound.

upper

A numeric such that values in response above it are considered to be anomalous. If NULL, there is no testing for values above the upper bound.

start.time

A numeric giving the start of the time interval, in terms of a level of times, during which testing for anomalous values is to occur. If NULL, the interval will start with the first observation.

end.time

A numeric giving the end of the time interval, in terms of a level of times, during which testing for anomalous values is to occur. If NULL, the interval will end with the last observation.

suffix.interval

A character giving the suffix to be appended to response to form the name of the column containing the calculated values. If it is NULL then nothing will be appended.

columns.retained

A character giving the names of the columns in data that are to be retained in the data.frame of anomalous individuals.

whichPrint

A character indicating what is to be printed. If anomalous is included, the columns.retained are printed for the anomalous individuals.

na.rm

A logical indicating whether NA values should be stripped before the testing proceeds.

...

allows for arguments to be passed to plotLongitudinal.

Value

A list with three components:

  1. data, a data frame resulting from the merge of data and the logical identifying whether or not an individual is anomalous;

  2. innerPlot, an object of class ggplot storing the profile plot of the individuals that are not anomalous;

  3. outerPlot, an object of class ggplot storing the profile plot of only the individuals that are anomalous.

The name of the column indicating anomalous individuals will be result of concatenating the response, anom and, if it is not NULL, suffix.interval, each separated by a full stop. The ggplot objects can be plotted using print and can be modified by adding ggplot functions before printing. If there are no observations to plot, NULL will be returned for the plot.

Author(s)

Chris Brien

See Also

anom, byIndv4Intvl_ValueCalc, ggplot.

Examples

data(exampleData)
anomalous <- plotAnom(longi.dat, response="sPSA.AGR", 
                      times = "xDAP", 
                      lower=2.5, start.time=40, 
                      vertical.line=29, 
                      breaks=seq(28, 42, by=2), 
                      whichPrint=c("innerPlot"), 
                      y.title="sPSA AGR")

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