Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Last active August 29, 2015 14:12
Show Gist options
  • Save abikoushi/257879c4e77509dd7499 to your computer and use it in GitHub Desktop.
Save abikoushi/257879c4e77509dd7499 to your computer and use it in GitHub Desktop.
calculate a increase rate & the contribution.
grow <- function(x){diff(x)/x[-length(x)]} #a rate of change.
cont <- function(a,all){ #contribution
grow(a) * (a/all)[-length(a)]
}
@abikoushi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment