Description Usage Arguments Details Value See Also Examples

View source: R/quest_functions.R

`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.

1 |

`x` |
numeric vector. |

`n` |
integer vector with length 1. Specifies how the change score is
calculated. If |

`undefined` |
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 `round`

within `shift`

if `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 `shift`

.

an atomic vector of the same length as `x`

that is the change
score. If `x`

and `undefined`

are different typeofs, then the
return will be coerced to the most complex typeof (i.e., complex to simple:
character, double, integer, logical).

`changes`

`change_by`

`changes_by`

`shift`

1 2 3 4 5 6 7 8 9 10 | ```
change(x = attitude[[1]], n = -1L) # use L to prevent problems with floating point numbers
change(x = attitude[[1]], n = -2L) # can specify any integer up to the length of `x`
change(x = attitude[[1]], n = +1L) # can specify negative or positive integers
change(x = attitude[[1]], n = +2L, undefined = -999) # user-specified indefined value
change(x = attitude[[1]], n = -2L, undefined = -999) # user-specified indefined value
change(x = attitude[[1]], 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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.