returns | R Documentation |
Computes periodic returns from a dataframe ordered by date
returns(df = dflong, retType = "abs", period.return = 1, spread = FALSE)
df |
Long dataframe with colnames = c("date","value","series"). |
retType |
"abs" for absolute, "rel" for relative, or "log" for log returns. |
period.return |
Number of rows over which to compute returns. |
spread |
TRUE if you want to spread into a long dataframe. |
A dataframe object of returns. tibble
Philippe Cote
x <- dflong %>% dplyr::filter(grepl("CL01", series))
returns(df = x, retType = "abs", period.return = 1, spread = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.