changes creates change scores (aka difference scores) from numeric
data. It is assumed that the data is already sorted by time such that the
first row is earliest in time and the last row is the latest in time.
changes is a multivariate version of
change that operates
on multiple variabes rather than just one.
data.frame of data.
character vector of colnames from
integer vector with length 1. Specifies how the change score is
atomic vector with length 1 (probably makes sense to be the
same typeof as
character vector of length 1 specifying the string to append to
the end of the colnames of the return object. The default depends on the
It is recommended to use
L when specifying
n to prevent
problems with floating point numbers.
shifts tries to circumvent this
issue by a call to
n is not an
integer; however that is not a complete fail safe. The problem is that
as.integer(n) implicit in
shifts truncates rather than rounds.
See details of
data.frame of change scores with colnames specified by
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
changes(attitude, vrb.nm = names(attitude), n = -1L) # use L to prevent problems with floating point numbers changes(attitude, vrb.nm = names(attitude), n = -2L) # can specify any integer up to the length of `x` changes(attitude, vrb.nm = names(attitude), n = +1L) # can specify negative or positive integers changes(attitude, vrb.nm = names(attitude), n = +2L, undefined = -999) # user-specified indefined value changes(attitude, vrb.nm = names(attitude), n = -2L, undefined = -999) # user-specified indefined value ## Not run: changes(str2str::d2d(InsectSprays), names(InsectSprays), n = 3L) # character vector returns an error ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.