library(dplyr)
index_daily <- tk_make_timeseries("2016-01-01", "2017-01-01", by = "day")
index_min <- tk_make_timeseries("2016-01-01", "2017-01-01", by = "min")
# How it works
# - Returns TRUE/FALSE length of index
# - Use sum() to tally the number of TRUE values
index_daily %>% between_time("start", "2016-01") %>% sum()
# ---- INDEX SLICING ----
# Daily Series: Month of January 2016
index_daily[index_daily %>% between_time("start", "2016-01")]
# Daily Series: March 1st - June 15th, 2016
index_daily[index_daily %>% between_time("2016-03", "2016-06-15")]
# Minute Series:
index_min[index_min %>% between_time("2016-02-01 12:00", "2016-02-01 13:00")]
# ---- FILTERING WITH DPLYR ----
FANG %>%
group_by(symbol) %>%
filter(date %>% between_time("2016-01", "2016-01"))
Run the code above in your browser using DataLab