percentage_change: Function to calculate percentage change between new and old...

View source: R/percentage_change.R

percentage_changeR Documentation

Function to calculate percentage change between new and old values.

Description

Function to calculate percentage change between new and old values.

Usage

percentage_change(previous, new, as_decimal = FALSE)

Arguments

previous

Previous or older value.

new

Newer value.

as_decimal

Should the percentage be represented in a 0 to 1 scale?

Value

Numeric vector.

Author(s)

Stuart K. Grange

See Also

percentage_difference

Examples


# Simple calculations
percentage_change(100, 50)
percentage_change(50, 100)

# Global mean CO2 mole fraction
percentage_change(277, 400)
percentage_change(277, 400, as_decimal = TRUE)

# Percentage change depends on the order of the inputs because it depends on
# the denominator
percentage_change(104, 130)
percentage_change(130, 104)


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.