library(purrr)
library(readr)
library(httr)
library(rvest)
library(dplyr)
library(lubridate)
"https://github.com/FinanceData/marcap/tree/master/data" %>%
GET() %>%
httr::content() %>%
html_nodes("td.content span a") %>%
html_text -> tar_list
tar_list %>%
map(~ download.file(
paste0("https://github.com/FinanceData/marcap/raw/master/data/",.x),
paste0("./data-raw/",.x)))
tar_list %>%
paste0("./data-raw/", .) %>%
map_dfr(~ read_csv(.x) %>%
mutate(MarcapRatio = ifelse(is.character(MarcapRatio), as.numeric(MarcapRatio),MarcapRatio)) %>%
mutate(ForeignShares = ifelse(is.character(ForeignShares), as.numeric(ForeignShares),ForeignShares)) %>%
mutate(ForeignRatio = ifelse(is.character(ForeignRatio), as.numeric(ForeignRatio),ForeignRatio))
) -> marcap
marcap %>%
mutate(chunk = paste0("mc",year(Date))) %>%
split(.$chunk) %>%
map(select, -chunk) %>%
iwalk(~ saveRDS(.x, paste0("./data/",.y,".rds"), compress = "bzip2"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.