growthPheno (version 1.0-13)

intervalValueCalculate: Calculates a single value that is a function of an individual's values for a response over a specified time interval

Description

Splits the values of a response into subsets corresponding individuals and applies a function that calculates a single value from each individual's observations during a specified time interval. It includes the ability to calculate the observation that corresponds to the calculated value of the function.

Usage

intervalValueCalculate(response, weights=NULL, individuals = "Snapshot.ID.Tag",
                       FUN = "max", which.obs = FALSE, which.levels = NULL, 
                       start.time=NULL, end.time=NULL, times.factor = "Days", 
                       suffix.interval=NULL, data, sep=".", na.rm=TRUE, ...)

Arguments

response

A character giving the name of the column in data from which the values of FUN are to be calculated.

weights

A character giving the name of the column in data containing the weights to be supplied as w to FUN.

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 value for an individual.

FUN

A character giving the name of the function that calculates the value for each subset.

which.obs

A logical indicating whether or not to determine the observation corresponding to the value of the function, instead of the value of the function itself.

which.levels

A character giving the name of the factor whose levels are to be identified as the level of the observation whose value matches the value of the function.

start.time

A numeric giving the times, in terms of levels of times.factor, that will give a single value for each Snapshot.ID.Tag and that will be taken as the observation at the start of the interval for which the growth rate is to be calculated. If start.time is NULL, the interval will start with the first observation.

end.time

A numeric giving the times, in terms of levels of times.factor, that will give a single value for each Snapshot.ID.Tag and that will be taken as the observation at the end of the interval for which the growth rate is to be calculated. If end.time is NULL, the interval will end with the last observation.

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 should be numeric values stored as characters.

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.

data

A data.frame containing the column from which the function is to be calculated.

na.rm

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

sep

A character giving the separator to use when the levels of individuals are combined. This is needed to avoid using a character that occurs in a factor to delimit levels when the levels of individuals are combined to identify subsets.

...

allows for arguments to be passed to FUN.

Value

A data.frame, with the same number of rows as there are individuals, containing a column for the individuals, a column with the values of the function for the individuals, and a column with the values of the times.factor. The name of the column with the values of the function will be result of concatenating the response, FUN and, if it is not NULL, suffix.interval, each separated by a full stop.

See Also

intervalGRaverage, intervalGRdiff, intervalWUI, splitValueCalculate, getTimesSubset

Examples

Run this code
# NOT RUN {
data(exampleData)
Area.smooth.max <- intervalValueCalculate("Area.smooth", 
                                          start.time = 31, end.time = 35, 
                                          suffix.interval = "31to35",
                                          data = longi.dat)
# }

Run the code above in your browser using DataCamp Workspace