library(BatchGetSymbols)

indexes <- c('^BVSP', '^GSPC', '^FTSE', '^N225')

df_indices <- BatchGetSymbols(tickers = indexes, 
                              first.date = '2010-01-01',
                              last.date = Sys.Date())[[2]]

tab_tidy <- df_indices %>%
  group_by(ticker) %>%
  summarise(mean_ret = mean(ret.adjusted.prices, na.rm = TRUE),
            max_ret = max(ret.adjusted.prices, na.rm = TRUE),
            min_ret = min(ret.adjusted.prices, na.rm = TRUE))

print(tab_tidy)
# none
my_answers <- rep(NA, 5)

Question

Refaça o exercício anterior utilizando as funções group_by e summarise, ambas do pacote dplyr.

Solution


Meta-information

extype: string exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE) exname: "batchgetsymbols dplyr" exshuffle: TRUE



msperlin/adfeR documentation built on March 26, 2021, 3:05 a.m.