For the column specified in imageTimes, having converted it to POSIXct if not already converted, calculates for each value the number of intervalUnits between the time and the startTime. Then the number of timePositions within the intervals is calculated for the values in imageTimes. The function difftimes is used in doing the calculations, but the results are converted to numeric. For example intervals could correspond to the number of Days after Planting and the timePositions to the hour within each day.
calcTimes(data, imageTimes = NULL, timeFormat = "%Y-%m-%d %H:%M",
intervals = "Time.after.Planting..d.", startTime = NULL,
intervalUnit = "days", timePositions = NULL)A data.frame containing any columns specified by
imageTimes, intervals and timePositions.
A character giving the name of the column that contains
the time that each cart was imaged. Note that in importing data into R, spaces
and nonalphanumeric characters in names are converted to full stops.
If imageTimes is NULL then no calculations are done.
A character giving the POSIXct format of characters
containing times, in particular imageTimes and startTime.
Note that if fractions of seconds are required options(digits.secs)
must be used to set the number of decimal places and timeFormat must
use %OS for seconds in timeFormat.
A character giving the time, in the POSIXct
format specified by timeFormat, to be subtracted from
imageTimes to caclualte intervals. For example, it might be the
day of planting or treatment. If startTime is
NULL then intervals is not calculated.
A character giving the name of the unit in which
the values of the intervals should be expressed. It must be one of "secs",
"mins", "hours" or "days".
A data.frame, being the unchaged data data.frame when
imageTimes is NULL or containing
either intervals and/or timePositions depending on which is not NULL.
# NOT RUN {
data(exampleData)
raw.dat <- calcTimes(data = raw.dat,
imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour")
# }
Run the code above in your browser using DataLab