# calcLagged

0th

Percentile

##### Replaces the values in a vector with the result of applying an operation to it and a lagged value

Replaces the values in x with the result of applying an operation to it and the value that is lag positions either before it or after it in x, depending on whether lag is positive or negative. For positive lag the first lag values will be NA, while for negative lag the last lag values will be NA. When operation is NULL, the values are moved lag positions down the vector.

Keywords
manip, data
##### Usage
calcLagged(x, operation = NULL, lag = 1)
##### Arguments
x

A vector containing the values on which the calculations are to be made.

operation

A character giving the operation to be performed on pairs of values in x. If operation is NULL then the values are moved lag positions down the vector.

lag

A integer specifying, for the second value in the pair to be operated on, the number positions it is ahead of or behind the current value.

##### Value

A vector containing the result of applying operation to values in x. For positive lag the first lag values will be NA, while for negative lag the last lag values will be NA.

Ops

• calcLagged
##### Examples
# NOT RUN {
data(exampleData)
longi.dat$Days.diffs <- calcLagged(longi.dat$xDays, operation ="-")
# }

Documentation reproduced from package growthPheno, version 1.0-13, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.