byIndv4Times_GRsDiff: Adds, to a 'data.frame', the growth rates calculated for...

byIndv4Times_GRsDiffR Documentation

Adds, to a data.frame, the growth rates calculated for consecutive times for individuals in a data.frame in long format by differencing response values.

Description

Uses AGRdiff, PGR and RGRdiff to calculate growth rates continuously over time for the response by differencing pairs of pairs of response values and stores the results in data. The subsets are those values with the same levels combinations of the factors listed in individuals.

Usage

byIndv4Times_GRsDiff(data, responses, 
                     individuals = "Snapshot.ID.Tag", times = "DAP", 
                     which.rates = c("AGR","PGR","RGR"), 
                     suffices.rates=NULL, sep.rates = ".", 
                     avail.times.diffs = FALSE, ntimes2span = 2)

Arguments

data

A data.frame containing the columns for which growth rates are to be calculated.

responses

A character giving the names of the columns in data for which growth rates are to be calculated.

individuals

A character giving the name(s) of the factor(s) that define the subsets of response that correspond to the response values for an individual (e.g. plant, pot, cart, plot or unit) for which growth rates are to be calculated continuously. If the columns corresponding to individuals are not factor(s) then they will be coerced to factor(s). The subsets are formed using split.

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. It will be used in calculating the growth rates. If a factor or character, the values should be numerics stored as characters.

which.rates

A character giving the growth rates that are to be calculated. It should be a combination of one or more of "AGR", "PGR" and "RGR".

suffices.rates

A character giving the characters to be appended to the names of the responses to provide the names of the columns containing the calculated growth rates. The order of the suffices in suffices.rates should correspond to the order of the elements of which.rates. If NULL, the values of which.rates are used.

sep.rates

A character giving the character(s) to be used to separate the suffices.rates value from a response value in constructing the name for a new rate. For no separator, set to "".

avail.times.diffs

A logical indicating whether there is an appropriate column of times diffserences that can be used as the denominator in computing the growth rates. If TRUE, it will be assumed that the name of the column is the value of times with .diffs appended. If FALSE, a column, whose column name will be the value of times with .diffs appended, will be formed and saved in the result, overwriting any existing columns with the constructed name in data. It will be calculated using the values of times in data.

ntimes2span

A numeric giving the number of values in times to span in calculating growth rates by differencing. Each growth rate is calculated as the difference in the values of one of the responses for pairs of times values that are spanned by ntimes2span times values divided by the difference between this pair of times values. For ntimes2span set to 2, a growth rate is the difference between consecutive pairs of values of one of the responses divided by the difference between consecutive pairs of times values.

Value

A data.frame containing data to which has been added i) a column for the differences between the times, if it is not already in data, and (ii) columns with growth rates. The name of the column for times differences will be the value of times with ".diffs" appended. The name for each of the growth-rate columns will be either the value of response with one of ".AGR", ".PGR" or "RGR", or the corresponding value from suffices.rates appended. Each growth rate will be positioned at observation ceiling(ntimes2span + 1) / 2 relative to the two times from which the growth rate is calculated.

Author(s)

Chris Brien

See Also

smoothSpline, byIndv4Times_SplinesGRs

Examples

data(exampleData)
longi.dat <- byIndv4Times_GRsDiff(data = longi.dat, 
                                  response = "sPSA", 
                                  individuals = "Snapshot.ID.Tag", 
                                  times = "DAP", 
                                  which.rates=c("AGR", "RGR"), 
                                  avail.times.diffs = TRUE)

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