powered by
Computes periodic returns from a dataframe ordered by date
returns(df = dflong, retType = "abs", period.return = 1, spread = FALSE)
A dataframe object of returns. tibble
tibble
Long dataframe with colnames = c("date","value","series"). character
character
"abs" for absolute, "rel" for relative, or "log" for log returns. character
Number of rows over which to compute returns. numeric
numeric
TRUE if you want to spread into a long dataframe. logical
logical
Philippe Cote
x <- dflong %>% dplyr::filter(grepl("CL01", series)) returns(df = x, retType = "abs", period.return = 1, spread = TRUE)
Run the code above in your browser using DataLab