Calculate daily growth rate of a cryptocurrency

daily_growth_rate(df, col_name)

Arguments

df

A Data frame with date and price data.

col_name

a string indicate the column holding daily closing price data.

Value

A dataframe with a new column of daily growth rate.

Examples

price_df = data.frame('Date'=c('2022-01-15', '2022-01-16'), 'Close'=c(1.5, 2.5))
daily_growth_rate(price_df, "Close")
#>         Date Close daily_growth_rate
#> 1 2022-01-15   1.5                NA
#> 2 2022-01-16   2.5          66.66667