Learn R Programming

growthPheno (version 3.1.18)

byIndv4Times_periodicRates: Adds the necessary times and rates values to a data.frame to make a set of periodic, or equally spaced, rates.

Description

Adds the times and rates values to a data.frame to produce a set of periodic rates i.e. rates for equally spaced times, the difference between consecutive times being equal to reqd.times.diff. This assumes that the values for the consecutive differences between the values in the times column in data are an integer multiple of the value of reqd.times.diff and involves inserting times when the integer multiple of a times value is greater than one. It is also assumed that it is appropriate to use the rate value for the time immediately following inserted time(s) for the rate value(s) for the inserted times. Additional columns can be specified to have values duplicated for the inserted times.

If avail.time.diffs is FALSE, the differences between consecutive time values in data are calculated.

Usage

byIndv4Times_periodicRates(data, responses, 
                           individuals = "Snapshot.ID.Tag", 
                           times = "DAP", 
                           columns2duplicate = NULL, 
                           reqd.times.diff = 1, 
                           avail.times.diffs = FALSE)

Value

A data.frame obtained by expanding data to include all combinations of the values of individuals and the set of equally spaced times between the minimum and maximun values of times, the spacing being the value of reqd.times.diff. For the rate(s) specified in the argument responses, values of the rate for the times immediately above an inserted times value are assigned to the values of the responses for the inserted

times.

Arguments

data

A data.frame containing the columns for responses, individuals and times.

responses

A character giving the names of the columns in data that contains rates that are to be made periodic by inserting extra times and responses values to create the data for a set of of equally spaced times separated by reqd.times.diff.

individuals

A character giving the name(s) of the factor(s) that define(s) the subsets of response that correspond to the response values for an individual (e.g. plant, pot, cart, plot or unit). If the column(s) 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, either as a numeric, factor, or character, at which the data was collected. If a factor or character, the values should be numerics stored as characters.

columns2duplicate

A character giving the name(s) of columns in data whose values are to be duplicated alongside the inserted times and responses. Generally, these should be columns whose values do not differ between the times values.

reqd.times.diff

A single-valued numeric giving the time difference required for the set of equally spaced times. A natural value for this is the unit of time for the rates specified in responses. For example, for a rate that measures the change per day, the unit of time is one day and so 1 is the natural value for reqd.times.diff. All time differences in data must be an integer multiple of reqd.times.diff for a set of equally spaced times to be possible.

avail.times.diffs

A logical indicating whether there is an appropriate column of times differences in data that can be used as the denominator in computing the 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.

Author

Chris Brien

See Also

byIndv4Times_WaterUse

Examples

Run this code
data(exampleData)
longi.dat <- within(longi.dat, WUR <- WU/DAP.diffs)
longi.dat <- byIndv4Times_periodicRates(data = longi.dat, 
                                        responses = "WUR", 
                                        individuals = "Snapshot.ID.Tag", 
                                        times = "DAP", 
                                        avail.times.diffs = TRUE)

Run the code above in your browser using DataLab