In an earlier article, a way to download stock price data files from Google, save it into a local drive and merge them into a single data frame. If files are not large, however, it wouldn’t be effective and, in this article, files are downloaded and merged internally.
The following packages are used.
Taking urls as file locations, files are directly read using llply and they are combined using rbind_all. As the merged data has multiple stocks’ records, Code column is created. Note that, when an error occurrs, the function returns a dummy data frame in order not to break the loop - values of the dummy data frame(s) are filtered out at the end.
Some of the values are shown below.
It took a bit longer to complete the script as I had to teach myself how to handle errors in R. And this is why I started to write articles in this blog.