pc: Calculate percentage change

View source: R/utils_extra.R

pcR Documentation

Calculate percentage change

Description

Calculate percentage change

Usage

pc(x, n, order_by = NULL)

Arguments

x

A numeric vector

n

Positive integer of length 1, giving the number of positions to lead or lag by

order_by

Override the default ordering to use another vector or column

Examples

df <- data.frame(time = c(1,2,3,4), x = c(100,101,100,98))
dplyr::mutate(df, d = pc(x, 1, time))
dplyr::mutate(df, d = pc(x, 1))

pttry/pttdatahaku documentation built on Jan. 25, 2025, 10:37 a.m.