change creates a change score (aka difference score) from a numeric
vector. It is assumed that the vector is already sorted by time such that the
first element is earliest in time and the last element is the latest in time.
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
It is recommended to use
L when specifying
n to prevent
problems with floating point numbers.
shift 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
shift truncates rather than rounds.
See details of
an atomic vector of the same length as
x that is the change
undefined are different typeofs, then the
return will be coerced to the most complex typeof (i.e., complex to simple:
character, double, integer, logical).
1 2 3 4 5 6 7 8 9 10
change(x = attitude[], n = -1L) # use L to prevent problems with floating point numbers change(x = attitude[], n = -2L) # can specify any integer up to the length of `x` change(x = attitude[], n = +1L) # can specify negative or positive integers change(x = attitude[], n = +2L, undefined = -999) # user-specified indefined value change(x = attitude[], n = -2L, undefined = -999) # user-specified indefined value change(x = attitude[], n = 0L) # returns a vector of zeros ## Not run: change(x = setNames(object = letters, nm = LETTERS), 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.