Skip to content

Instantly share code, notes, and snippets.

@mribeirodantas
Created April 5, 2020 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mribeirodantas/67e7027faa9b542c043d34f00893d59c to your computer and use it in GitHub Desktop.
Save mribeirodantas/67e7027faa9b542c043d34f00893d59c to your computer and use it in GitHub Desktop.
> A <- c(1,1,1,1,1,1,1,1,8,10)
> B <- c(1,2,3,4,5,6,7,8,9,10)
> growth_rate(A)
[1] NA 0 0 0 0 0 0 0 700 25
> sum(growth_rate(A), na.rm=TRUE)/length(A)
[1] 72.5
>
> growth_rate(B)
[1] NA 100.00000 50.00000 33.33333 25.00000 20.00000 16.66667 14.28571 12.50000
[10] 11.11111
> sum(growth_rate(B), na.rm=TRUE)/length(B)
[1] 28.28968
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment