This can be used, for example to take survival ratios.

ratx(fx, k = 1)

Arguments

fx

numeric. Vector of length > k.

k

integer. The size of the lag in elements of fx.

Details

Behavior similar to diff(), in that returned vector is k elements shorter than the given vector fx.

Examples

fx <- 1:10 ratx(fx)
#> [1] 2.000000 1.500000 1.333333 1.250000 1.200000 1.166667 1.142857 1.125000 #> [9] 1.111111
ratx(fx,-1)
#> [1] 0.5000000 0.6666667 0.7500000 0.8000000 0.8333333 0.8571429 0.8750000 #> [8] 0.8888889 0.9000000
ratx(fx,0)
#> [1] 1 2 3 4 5 6 7 8 9 10