forked from sstoeckl/ffdownload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
58 lines (44 loc) · 2.32 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# FFdownload <a href='https://github/sstoeckl/FFdownload'><img src='man/figures/logo.png' align="right" height="139" /></a>
<!-- badges: start -->
[![Travis build status](https://travis-ci.org/sstoeckl/ffdownload.svg?branch=master)](https://travis-ci.org/sstoeckl/ffdownload)
<!-- badges: end -->
`R` Code to download Datasets from [Kenneth French's famous website](http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html).
## Motivation
Well, one often needs those datasets for further empirical work and it is a tedious effort to download the (zipped) csv open and then manually seperate them
## Contributors
Original code from MasimovR <https://github.com/MasimovR/>
## Installation
You can install FFdownload from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("sstoeckl/ffdownload")
```
## Example
```{r example, eval=FALSE}
tempf <- tempfile(fileext = ".RData"); tempd <- tempdir(); temptxt <- tempfile(fileext = ".txt")
# Example 1: Use FFdownload to get a list of all monthly zip-files. Save that list as temptxt.
FFdownload(exclude_daily=TRUE,download=FALSE,download_only=TRUE,listsave=temptxt)
# set vector with only files to download (we tray a fuzzyjoin, so "Momentum" should be enough to get the Momentum Factor)
inputlist <- c("F-F_Research_Data_Factors","F-F_Momentum_Factor","F-F_ST_Reversal_Factor","F-F_LT_Reversal_Factor")
# Now process only these files if they can be matched (download only)
FFdownload(exclude_daily=TRUE,tempdir=tempd,download=TRUE,download_only=TRUE,inputlist=inputlist)
# Then process all the downloaded files
FFdownload(output_file = tempf, exclude_daily=TRUE,tempdir=tempd,download=FALSE,download_only=FALSE,inputlist=inputlist)
load(tempf); FFdownload$`x_F-F_Momentum_Factor`$monthly$Temp2[1:10]
# Example 2: Download all non-daily files and process them
tempf2 <- tempfile(fileext = ".RData"); tempd2 <- tempdir()
FFdownload(output_file = tempf2,tempdir = tempd2,exclude_daily = TRUE, download = TRUE, download_only=FALSE, listsave=temptxt)
load(tempf2)
FFdownload$x_25_Portfolios_5x5$monthly$average_value_weighted_returns
```