| byIndv_ValueCalc {growthPheno} | R Documentation |
Calculates a single value that is a function of an individual's values for a response.
Description
Applies a function to calculate a single value from
an individual's values for a response in a data.frame in
long format.
It includes the ability to calculate the observation number
that is closest to the calculated value of the function and
the assocated values of a factor or numeric.
Usage
byIndv_ValueCalc(data, response, individuals = "Snapshot.ID.Tag",
FUN = "max", which.obs = FALSE, which.values = NULL,
addFUN2name = TRUE, sep.FUNname = ".",
weights = NULL, na.rm=TRUE, sep.levels = ".", ...)
Arguments
data |
A |
response |
A |
individuals |
A |
FUN |
A |
which.obs |
A |
which.values |
A |
addFUN2name |
A |
sep.FUNname |
A |
weights |
A |
na.rm |
A |
sep.levels |
A |
... |
allows for arguments to be passed to |
Value
A data.frame, with the same number of rows as there are
individuals, containing a column for the individuals and
a column with the values of the function for the individuals.
It is also possible to determine observaton numbers or the values of
another column in data for the response values that are
closest to the FUN results, using either or both of
which.obs and which.values. If which.obs is
TRUE, a column with observation numbers is included in the
data.frame.
If which.values is set to the name of a factor or
a numeric,a column containing the levels of that
factor or the values of that numeric is
included in the data.frame.
The name of the column with the values of the function will be formed by
concatenating the response and FUN, separated by a full stop.
If which.obs is TRUE, the column name for the obervations
numbers will have .obs added after FUN into the column name
for the function values; if which.values is specified,
the column name for these values will have a full stop followed by
which.values added after FUN into the column name
for the function values.
Author(s)
Chris Brien
See Also
byIndv4Intvl_ValueCalc, byIndv4Times_GRsDiff,
byIndv4Times_SplinesGRs
Examples
data(exampleData)
sPSA.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "PSA")
AGR.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA.AGR",
FUN="max",
which.values = "DAP", which.obs = TRUE)
sPSA.dec1.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA",
FUN="quantile",
which.values = "DAP", probs = 0.1)