calculate_percentage_change: Calculate percentage change.

Description Usage Arguments Details Value Examples

View source: R/calculate_percentage_change.R

Description

Calculate percentage change over a time period for the given column pattern.

Usage

1
2
3
4
5
6
calculate_percentage_change(
  df,
  pattern,
  compare_period = c(2, 2),
  time_filter = NULL
)

Arguments

df

A tibble or Data frame

pattern

A string representing column pattern

compare_period

A numeric vector of comparison period

time_filter

A numeric vector of time filter

Details

This function aims to generate features such as percentage change in last month versus last to last month to capture trend in data for a given comparison period. For example, In Telecommunication it can be used to generate features useful for predicting subscribers who are more likely to decline their revenue next month/week. In Finance it can be used to generate features useful for predicting customers who are going to default next month/week.

Value

A vector with calculated percentage change

Examples

1
2
3
4
5
6
7
df <- data.frame(
    week_payment1 = c(1, 2, 3),
    week_payment2 = c(4, 5, 6),
    week_payment3 = c(7, 8, 9),
    week_payment4 = c(10, 11, 12)
)
calculate_percentage_change(df, "week_payment")

UBC-MDS/featurescreator documentation built on Feb. 5, 2022, 8:12 a.m.