# NOT RUN {
# Libraries
library(tidyquant)
library(timetk)
library(tidyverse)
library(forcats)
# --- Basic Usage ----
SUM(1:10)
PCT_CHANGE_FIRSTLAST(c(21, 24, 22, 25))
# --- Usage with tidyverse ---
# Go from daily to monthly periodicity,
# then calculate returns and growth of $1 USD
FANG %>%
mutate(symbol = as_factor(symbol)) %>%
group_by(symbol) %>%
# Summarization - Collapse from daily to FIRST value by month
summarise_by_time(
.date_var = date,
.by = "month",
adjusted = FIRST(adjusted)
)
# }
Run the code above in your browser using DataLab