Package: capenewsindex 0.1.0

CAPE ERC

capenewsindex: Build News-Based Uncertainty Indices from Newspaper Archives

Build news-based uncertainty indices (EPU, TPU, or any index defined from two or more keyword groups) from newspaper archives, for any country and language, using the Baker, Bloom and Davis (2016) method <doi:10.1093/qje/qjw024>. Supply the articles, the keywords and, for group indices, GDP. One call gives country indices (with or without a history period) and GDP-weighted indices for groups of countries. This is the R counterpart of the Python 'CAPEnewsindex' library (<https://github.com/CAPE-ERC/cape-newsindex>).

Authors:Shakir Adeyemi Tewogbade [aut, cph], Ayodeji Badmus [aut], Akande Omotayo Emmanuel [aut], Honey Adenike Adeleke [aut], Kafayat Alobaloke [aut], Taiwo Oyedamola [aut], Pelumi Oluwategbe [aut], Samuel Monday [aut], Laniran Temitope [aut], CAPE ERC [cre, cph]

capenewsindex_0.1.0.tar.gz
capenewsindex_0.1.0.zip(r-4.7-any)capenewsindex_0.1.0.zip(r-4.6-any)capenewsindex_0.1.0.zip(r-4.5-any)
capenewsindex_0.1.0.tgz(r-4.6-any)capenewsindex_0.1.0.tgz(r-4.5-any)
capenewsindex_0.1.0.tar.gz(r-4.7-any)capenewsindex_0.1.0.tar.gz(r-4.6-any)
capenewsindex_0.1.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION
card.svg |card.png
capenewsindex/json (API)

# Install 'capenewsindex' in R:
install.packages('capenewsindex', repos = c('https://cape-erc.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/cape-erc/capenewsindex-r/issues

On CRAN:

Conda:

2.00 score 102 exports 3 dependencies

Last updated from:0a14ecc205. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK158
source / vignettesOK250
linux-releaseOK120
macos-releaseOK150
macos-oldrelOK77
windows-develOK85
windows-releaseOK70
windows-oldrelOK91
wasm-releaseOK107

Exports:aggregate_freeze_weights_afteraggregate_indexaggregate_monthly_gdparticles_for_each_batchbuild_indexcountriescountry_dictionary_termscoveragedashboard_builddashboard_writededup_article_keydedup_canonical_urldedup_cape_canonical_urldedup_dedupedescribe_indexdictionary_coveragedictionary_fingerprintdictionary_for_countriesdictionary_from_dictdictionary_from_tabledictionary_from_textdictionary_getdictionary_group_namesdictionary_loaddictionary_readdictionary_save_keywordsdictionary_to_tabledictionary_to_textdictionary_validateEPU_GROUPSFORMATS_HELPGDP_FREQUENCIESgroup_namehealth_checkhistory_loadhistory_retained_siteshistory_saveindex_compute_indexindex_countindex_count_archiveindex_fit_historyindex_matcherindex_matchesindex_scoreindex_score_windowsindex_value_columnkeywords_templateload_resultmatch_any_term_matchesmatch_component_patternmatch_find_termsmatch_is_epumatch_is_missingmatch_light_normalizematch_normalizematch_term_matchesnew_historyplot_compareplot_componentsplot_correlationplot_dashboardplot_distributionplot_heatmapplot_historyplot_indexplot_rankplot_regionsplot_rollingprint_periodread_articlesread_periodicrebase_indexreport_indexresample_indexresult_plotresult_saveresult_showresult_tableresult_widerun_indexrun_index_with_historysave_allsave_csvsave_excelsave_gsheetsave_jsonsave_parquetsave_plotsave_reportsave_resultsave_sqlsave_versionedsmooth_indexsummarize_indextheme_indextop_indexvalidate_archiveweights_customweights_equalweights_gdpweights_pcaweights_population

Dependencies:digestjsonlitestringi

Readme and manuals

Help Manual

Help pageTopics
Weights for later months frozen at an earlier month's valueaggregate_freeze_weights_after
Weighted group indices for blocks of countries you defineaggregate_index
Turn annual, quarterly or monthly GDP into one value per country-monthaggregate_monthly_gdp
Yield one small table per (country, year-month folder)articles_for_each_batch
Build an EPU-type index from a scraped-article archive in one callbuild_index
Global country reference tablecountries
Terms of one group for a country entrycountry_dictionary_terms
Which (country, year-month) combinations have article filescoverage
Build a self-contained HTML dashboard for an index resultdashboard_build
Write a self-contained HTML dashboarddashboard_write
The duplicate key of one articlededup_article_key
Normalize a URL for deduplication ('rules = "legacy"')dedup_canonical_url
The CAPE EPU index's link key ('rules = "cape"')dedup_cape_canonical_url
Drop duplicate articles within each groupdedup_dedupe
Per-country min/max/mean/std, plus the biggest month-over-month movedescribe_index
Which countries have an archive folder, a dictionary entry, or bothdictionary_coverage
A stable hash of the exact dictionary contentsdictionary_fingerprint
Keywords for a set of countries, expanding the shared '"*"' entrydictionary_for_countries
Keywords from an R listdictionary_from_dict
Keywords from a table with 'country', 'group' and 'term' columnsdictionary_from_table
Keywords from the plain-text formatdictionary_from_text
Get one country's entry from a dictionarydictionary_get
Every group name used by any country, in first-seen orderdictionary_group_names
Load an EPTU-schema JSON keyword filedictionary_load
Read keywords from any supported formdictionary_read
Write keywords to a filedictionary_save_keywords
All keywords as one readable tabledictionary_to_table
Keywords as plain textdictionary_to_text
Audit a dictionary for empty groups and cross-group overlapsdictionary_validate
The groups used by the EPU indexEPU_GROUPS
Accepted GDP/population period label formatsFORMATS_HELP
The frequencies a GDP file can have, and the months each period spansGDP_FREQUENCIES
Normalise a keyword-group namegroup_name
One-call "is everything wired up correctly" smoke test before a big runhealth_check
Save/load a history to/from JSONhistory_io history_load history_save
Newspapers retained for a country's historyhistory_retained_sites
Compute an in-sample index over a single window (no-history variant)index_compute_index
Count matching and total articles per country-site-monthindex_count
Count matching and total articles directly from an article archiveindex_count_archive
Fit newspaper standard deviations and country means over [start, end]index_fit_history
Build an index matcher for two or more keyword groupsindex_matcher
Match many texts against an index matcher at onceindex_matches
Score every country-month in 'counts' against a frozen historyindex_score
Score one or more later windows against a frozen history (with-history variant)index_score_windows
The index column of a result tableindex_value_column
Write the bundled keyword template as an editable filekeywords_template
Read back a table saved by 'save_result()'load_result
Does any of 'terms' occur in 'text'?match_any_term_matches
One compiled alternation matching normalized text that contains any of 'terms'match_component_pattern
Find which dictionary terms occur in a piece of textmatch_find_terms
Baker, Bloom and Davis (2016) classification rulematch_is_epu
Is a value missing?match_is_missing
'light_normalize': normalize without collapsing whitespacematch_light_normalize
Normalize text for matchingmatch_normalize
Does one term occur in already-normalized text?match_term_matches
Frozen history scaling parameters for a country indexnew_history
Line chart for a chosen set of countriesplot_compare
Stacked area chart of article counts (components of the index)plot_components
Compare one country's index with an external monthly seriesplot_correlation
Compose trend, ranking, and distribution chartsplot_dashboard
Distribution of the index across months, one box/violin per countryplot_distribution
Country x month heatmap of the indexplot_heatmap
Plot frozen history standard deviations by newspaperplot_history
One line/bar/area per country, zero configurationplot_index
Bar chart ranking countries at one monthplot_rank
One line per group index (GDP-weighted blocks)plot_regions
Rolling-average chart, one line per countryplot_rolling
Print the slice of 'result' with 'year_month' in [start, end]print_period
Read every article file under 'root' into one tableread_articles
Read an annual, quarterly or monthly by-country tableread_periodic
Recompute the 100-mean rescaling against a different reference periodrebase_index
Render a minimal one-page report to a filereport_index
Reshape 'result' from monthly to quarterly or annual averagesresample_index
Line chart, one colour per countryresult_plot
Save the results to a folderresult_save
Print a short summary and the latest months of the indexresult_show
One row per country (and version): months, latest value, average, highest monthresult_table
The country index as one column per countryresult_wide
Read an article archive and compute a single-window EPU index in one callrun_index
Read an article archive and score it against a frozen history in one callrun_index_with_history
Batch-save several result tables in several formats at oncesave_all
Save a result table as CSVsave_csv
Save a result table as a formatted '.xlsx' workbooksave_excel
Replace a worksheet with a result table in Google Sheetssave_gsheet
Save a result table as tidy records-oriented JSONsave_json
Save a result table as '.parquet'save_parquet
Save a 'ggplot' object to a filesave_plot
Render a report to '.html', '.md', '.docx' or '.pdf'save_report
Save a result table in the format implied by 'path''s extensionsave_result
Write a result table to a caller-provided database connectionsave_sql
Timestamped save so a re-run never silently overwrites the last onesave_versioned
Add a rolling-average smoothed column, per countrysmooth_index
Plain-English multi-line summary, one block per countrysummarize_index
A minimal theme tweak applied to the current ggplot2 defaulttheme_index
Top-'n' rows of 'result', sorted descending by column 'by'top_index
Sanity-check every file under an archive, without any EPU classificationvalidate_archive
Weight by an existing column of 'country_index' itselfweights_custom
Equal weighting: every country in the group counts the sameweights_equal
Thin wrapper around 'aggregate_monthly_gdp()'weights_gdp
Derive a composite weight from the first principal componentweights_pca
Turn annual, quarterly or monthly population into monthly valuesweights_population