Description Usage Arguments Details Value Examples
View source: R/calculate_percentage_change.R
Calculate percentage change over a time period for the given column pattern.
1 2 3 4 5 6 | calculate_percentage_change(
df,
pattern,
compare_period = c(2, 2),
time_filter = NULL
)
|
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 |
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.
A vector with calculated percentage change
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.