Description Usage Arguments Value
A function to calculate standardized differences between xi and the rolling mean of xi-1 to xi-n for given variables in a data frame. It calculates the difference between xi and the rolling mean. At the end it divides the calculated difference by the standard deviation and adds the results to dt
1 2 | addStandDiff(dt, nDays, groupVars = "calf", vars, dateColumn = "date",
sdMethod = "cumulative", group = FALSE)
|
dt |
data frame which includes the variables for which to calculate the standardized differences |
nDays |
number of days to use for rolling mean and rolling sd |
groupVars |
name of grouping variable ind dt if calculation should be done groupwise (e.g. for each calf individual).Must be Character. Default = '"calf"' |
vars |
character vector of variable names for which to calculate the standardized differences |
dateColumn |
name (character) of date column which is used to arrange data Default = '"date"' |
sdMethod |
parameter to choose how standard deviation (used for standardizing) is calculated: '"cumulative"' - calculates standard deviation from first value in vector (x[1]) to x[i] and updates it for every x[i] '"rolling"' - calculates running standard deviation within the same window as the rolling mean (-> nDays) |
Returns differnce to rolling mean 'diffToRollMean', rolling sd 'rollSD' and standardized differnece 'standardDiff' for all given variables and adds them to the data frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.