Created
November 3, 2018 18:59
-
-
Save mrchypark/daaa1848a4c10e24061ddae8eea314a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(purrr) | |
library(readr) | |
library(httr) | |
library(rvest) | |
library(dplyr) | |
"https://github.com/FinanceData/marcap/tree/master/data" %>% | |
GET() %>% | |
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/", .) -> tt | |
tt %>% | |
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 | |
use_data(marcap) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment