## code to prepare `catalog` dataset goes here
catalog_sz <- 13
url_prefix_FF <- 'http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp'
url_prefix_FF_doc <- 'http://mba.tuck.dartmouth.edu' %>%
stringr::str_glue('/pages/faculty/ken.french/Data_Library/')
url_prefix_FRED <- "https://api.stlouisfed.org/fred/"
catalog <- tibble::tibble(
alias_name = c(rep('', 4),
'T10Y', 'T1Y', 'Baa_Corp', 'Aaa_Corp',
'T10Y', 'T1Y', 'Baa_Corp', 'Aaa_Corp',
'CPI'),
desc = c('French-Fama 3-Factor US (Monthly)',
'French-Fama 3-Factor Developed (Monthly)',
'French-Fama Operating Profitability US (Monthly)',
'French-Fama Operating Profitability ex. Div. US (Monthly)',
'10-Year Treasury Constant Maturity Rate (Daily)',
'1-Year Treasury Constant Maturity Rate (Daily)',
"Moody's Seasonned Baa Corporate Bond Yield (Daily)",
"Moody's Seasonned Aaa Corporate Bond Yield (Daily)",
'10-Year Treasury Constant Maturity Rate (Monthly)',
'1-Year Treasury Constant Maturity Rate (Monthly)',
"Moody's Seasonned Baa Corporate Bond Yield (Monthly)",
"Moody's Seasonned Aaa Corporate Bond Yield (Monthly)",
'Consumer Price Index for All Urban Consumers'),
doc_src = c( stringr::str_glue(url_prefix_FF_doc, 'f-f_factors.html'),
stringr::str_glue(url_prefix_FF_doc, 'f-f_3developed.html'),
stringr::str_glue(url_prefix_FF_doc, 'det_port_form_op.html'),
stringr::str_glue(url_prefix_FF_doc, 'det_port_form_op.html'),
rep(stringr::str_glue(url_prefix_FRED, 'series'), 9)),
hdl = c('FF_3F_US_M', 'FF_3F_DEV_M', 'FF_OP_US_M', 'FF_OP_exDiv_US_M',
'FRED_T10Y_US_D', 'FRED_T1Y_US_D', 'FRED_Baa_US_D', 'FRED_Aaa_US_D',
'FRED_T10Y_US_M', 'FRED_T1Y_US_M', 'FRED_Baa_US_M', 'FRED_Aaa_US_M',
'FRED_CPI_US_M'),
hdl_names = list(
FF_3F_US_M =
tibble::tibble(names_ = c('year', 'month', 'mkt', 'smb', 'hml', 'rf')),
FF_3F_DEV_M =
tibble::tibble(names_ = c('year', 'month', 'mkt', 'smb', 'hml', 'rf')),
FF_OP_US_M =
tibble::tibble(names_ = c('year', 'month',
'Lo.30', 'Med.40', 'Hi.30',
'Lo.20', 'Qnt.2', 'Qnt.3', 'Qnt.4', 'Hi.20',
'Lo.10', 'Dec.2', 'Dec.3', 'Dec.4', 'Dec.5',
'Dec.6', 'Dec.7', 'Dec.8', 'Dec.9', 'Hi.10')),
FF_OP_exDiv_US_M =
tibble::tibble(names_ = c('year', 'month',
'Lo.30', 'Med.40', 'Hi.30',
'Lo.20', 'Qnt.2', 'Qnt.3', 'Qnt.4', 'Hi.20',
'Lo.10', 'Dec.2', 'Dec.3', 'Dec.4', 'Dec.5',
'Dec.6', 'Dec.7', 'Dec.8', 'Dec.9', 'Hi.10')),
FRED_T10Y_US_D =
tibble::tibble(names_ = c('date', 'T10Y')),
FRED_T1Y_US_D =
tibble::tibble(names_ = c('date', 'T11Y')),
FRED_Baa_US_D =
tibble::tibble(names_ = c('date', 'Baa_Corp')),
FRED_Aaa_US_D =
tibble::tibble(names_ = c('date', 'Aaa_Corp')),
FRED_T10Y_US_M =
tibble::tibble(names_ = c('date', 'T10Y')),
FRED_T1Y_US_M =
tibble::tibble(names_ = c('date', 'T1Y')),
FRED_Baa_US_M =
tibble::tibble(names_ = c('date', 'Baa_Corp')),
FRED_Aaa_US_M =
tibble::tibble(names_ = c('date', 'Aaa_Corp')),
FRED_CPI_US =
tibble::tibble(names_ = c('date', 'CPI'))),
internal_id = c( rep('', 4),
'DGS10', 'DGS1', 'DBAA', 'DAAA',
'GS10', 'GS1', 'BAA', 'AAA',
'CPIAUCSL'),
source = c(rep('Kenneth French Library', 4),
rep('FRED, Federal Reserve Bank of St. Louis', 9)),
url_src = c(paste(url_prefix_FF,
'/F-F_Research_Data_Factors_TXT.zip',
sep = ""),
paste(url_prefix_FF,
'/Developed_3_Factors_TXT.zip',
sep = ""),
paste(url_prefix_FF,
'/Portfolios_Formed_on_OP_TXT.zip',
sep = ""),
paste(url_prefix_FF,
'/Portfolios_Formed_on_OP_Wout_Div_TXT.zip',
sep = ""),
rep(url_prefix_FRED, 9)
)
)
stopifnot(length(unique(catalog$desc)) == catalog_sz)
stopifnot(length(unique(catalog$hdl)) == catalog_sz)
usethis::use_data(catalog, internal = T, overwrite = T)
remove(catalog)
remove(catalog_sz)
remove(url_prefix_FF)
remove(url_prefix_FF_doc)
remove(url_prefix_FRED)
# ------------------------------------------------------------------------------
# Managing API keys
file.edit("~/.Renviron")
Sys.setenv(VAR1 = 'value1')
Sys.getenv('VAR1')
Sys.getenv()
Sys.unsetenv('VAR1')
usethis::edit_r_environ()
fs::file_info("~/.Renviron")
fs::file_show("~/.Renviron")
# ------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.