This repository contains an R package that collects helper functions for developers and researchers familiar with Tidy Finance with R. The functions provide shortcuts to selected issues that the book discusses in detail.
You can install the released version of tidyfinance
from CRAN
via:
install.packages("tidyfinance")
You can install the development version of tidyfinance
from GitHub
via:
# install.packages("pak")
::pak("tidy-finance/r-tidyfinance") pak
The main functionality of the tidyfinance
package
centers around data download. You can download most of the data that we
used in Tidy Finance
with R using the download_data()
function or its
children. For instance, both functions give the same result:
download_data(
type = "factors_ff_3_monthly",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
download_data_factors_ff(
type = "factors_ff_3_monthly",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
You can also download data directly from WRDS
(if you have set your credentials via
Sys.setenv(WRDS_USER = "your_username", WRDS_PASSWORD = "your_password")
),
e.g.,
download_data(
type = "wrds_compustat_annual",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
If you want to fetch additional columns that are not included in our default selection, then pass them as additional arguments in the corresponding child function:
download_data_wrds_compustat(
type = "wrds_compustat_annual",
start_date = "2000-01-01",
end_date = "2020-12-31",
acoxar, amc, aldo )
You can get a list of all currently supported types via
list_supported_types()
. Please open an issue on
GitHub to request additional supported types.
We include functions to check out content from tidy-finance.org:
list_tidy_finance_chapters()
open_tidy_finance_website()
There are also some simple helpers for regression analyses:
winsorize()
trim()
create_summary_statistics()
We also include (experimental) functions that can be used for different applications, but note that they might heavily change in future package versions as we try to make them more general:
# For portfolio sorts
assign_portfolio()
# For beta estimation
estimate_model()