| Title: | Access the Political Science Replication Index from R |
|---|---|
| Description: | Search and browse the Political Science Replication Index (<https://jsakowuah.github.io/polisci-replication/>), a searchable, tagged index of replication packages crawled monthly from flagship political science journals' Harvard Dataverse collections, without leaving R. Provides functions to download and cache the index locally and to search and filter it by journal, method, data type, and year. |
| Authors: | Joseph Akowuah [aut, cre, cph] |
| Maintainer: | Joseph Akowuah <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-09-17 11:47:26 UTC |
| Source: | https://github.com/jsakowuah/psreplicate |
Looks up the record by DOI and opens its url with utils::browseURL(),
so you can go from a search result straight to the dataset itself without
copying a link.
browse_dataset(doi)browse_dataset(doi)
doi |
The dataset's DOI (see |
Invisibly, the URL that was opened.
browse_dataset("doi:10.7910/DVN/PRYYZ5")browse_dataset("doi:10.7910/DVN/PRYYZ5")
Look up a single record by DOI
dataset_info(doi)dataset_info(doi)
doi |
The dataset's DOI, e.g. |
A one-row tibble::tibble(), or a zero-row tibble if no record
matches (see search_replications() for the column definitions).
dataset_info("doi:10.7910/DVN/PRYYZ5")dataset_info("doi:10.7910/DVN/PRYYZ5")
Downloads a replication package's files to a local directory, without
leaving R. Requires the dataverse package
(install.packages("dataverse")); this is a thin convenience wrapper
around it, scoped to this index's data and DOI format.
download_dataset(doi, dest = tempfile("psreplicate_"), files = NULL)download_dataset(doi, dest = tempfile("psreplicate_"), files = NULL)
doi |
The dataset's DOI (see the |
dest |
Directory to download into. Created if it doesn't exist. Defaults to a new temporary directory. |
files |
Optional character vector of filenames to download (see
|
Invisibly, a character vector of the local file paths written. A file that fails to download (e.g. access-restricted) is skipped with a warning rather than aborting the rest of the download.
hit <- search_by_title("Rebel Victory and Authoritarian") download_dataset(hit$doi[1])hit <- search_by_title("Rebel Victory and Authoritarian") download_dataset(hit$doi[1])
The valid values to pass to search_by_data_type() or
search_replications()'s data_type argument aren't documented
anywhere else - this lists exactly what's actually in the data, most
common first.
list_data_types()list_data_types()
A tibble::tibble() with columns data_type and n_records.
list_data_types()list_data_types()
Previews what's available before downloading anything with
download_dataset(). Requires the dataverse package
(install.packages("dataverse")), which does the actual work of talking
to Harvard Dataverse's file API.
list_dataset_files(doi)list_dataset_files(doi)
doi |
The dataset's DOI (see the |
A tibble::tibble() with columns filename, filesize (bytes),
and content_type.
hit <- search_by_title("Rebel Victory and Authoritarian") list_dataset_files(hit$doi[1])hit <- search_by_title("Rebel Victory and Authoritarian") list_dataset_files(hit$doi[1])
A quick reference, since the API is spread across several small,
single-purpose functions rather than one do-everything call. Equivalent
information is available via library(help = "psreplicate"), but this is
meant to be more skimmable.
list_functions()list_functions()
A tibble::tibble() with columns function_name and
description, in the order you'd typically reach for them.
list_functions()list_functions()
List journals covered by the index
list_journals()list_journals()
A tibble::tibble() with one row per journal currently
represented in the index: journal_short, journal_name, and
n_records (the number of indexed replication packages).
list_journals()list_journals()
The valid values to pass to search_by_method() or
search_replications()'s method argument aren't documented anywhere
else - this lists exactly what's actually in the data, most common first.
list_methods()list_methods()
A tibble::tibble() with columns method and n_records.
list_methods()list_methods()
Unlike download_dataset(), this never writes anything to disk. Tabular
files (.tab/.dta/.csv/etc. that Dataverse has ingested) come back
as a tibble; .rds files are deserialized directly with readRDS() as
whatever R object they contain; other plain-text files (scripts,
READMEs) come back as a character vector of lines; anything else (PDFs,
images, other binaries) comes back as a raw vector, since there's no
sensible in-memory representation otherwise. Requires the
dataverse package (install.packages("dataverse")).
load_dataset_file(doi, filename)load_dataset_file(doi, filename)
doi |
The dataset's DOI (see the |
filename |
The file to load, exactly as it appears in
|
A tibble::tibble() for tabular files, whatever R object was
saved for .rds files, a character vector for plain-text files, or a
raw vector otherwise.
hit <- search_by_title("Rebel Victory and Authoritarian") load_dataset_file(hit$doi[1], "area.tab")hit <- search_by_title("Rebel Victory and Authoritarian") load_dataset_file(hit$doi[1], "area.tab")
Downloads the current Political Science Replication Index and stores it
in a per-session-independent, per-user cache directory (see
tools::R_user_dir()), so subsequent calls to search_replications()
and list_journals() don't need network access. The cache is refreshed
automatically once it is more than a day old; call this directly to force
an update sooner.
refresh_index(force = FALSE)refresh_index(force = FALSE)
force |
Logical; re-download even if a cached copy less than a day
old already exists. Default |
Invisibly, the path to the cached index file.
refresh_index()refresh_index()
Matches only the dataset's abstract/description text (the description
column), not title or authors.
search_by_abstract(query)search_by_abstract(query)
query |
Search term, matched case-insensitively as a substring. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_abstract("difference-in-differences")search_by_abstract("difference-in-differences")
Matches only the authors column (each a "Last, First; Last, First"
string), not title or abstract.
search_by_author(query)search_by_author(query)
query |
Search term, matched case-insensitively as a substring. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_author("Wantchekon")search_by_author("Wantchekon")
Get all records tagged with a given data type
search_by_data_type(data_type)search_by_data_type(data_type)
data_type |
Character vector of data-type tags; a record matches if it has at least one of the given tags. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_data_type("Elections / Voting")search_by_data_type("Elections / Voting")
Get all records from a journal
search_by_journal(journal)search_by_journal(journal)
journal |
Character vector of journal short codes (see
|
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_journal("AJPS") search_by_journal(c("AJPS", "APSR"))search_by_journal("AJPS") search_by_journal(c("AJPS", "APSR"))
Get all records tagged with a given method
search_by_method(method)search_by_method(method)
method |
Character vector of method tags; a record matches if it has at least one of the given tags. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_method("Survey Experiment")search_by_method("Survey Experiment")
Unlike search_replications()'s query argument, which matches across
title, abstract, and authors together, this matches only the title.
search_by_title(query)search_by_title(query)
query |
Search term, matched case-insensitively as a substring. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_title("regression discontinuity")search_by_title("regression discontinuity")
Get all records published in given year(s)
search_by_year(year)search_by_year(year)
year |
Integer vector of publication years, e.g. |
A tibble::tibble() of matching records (see search_replications()
for the column definitions).
search_by_year(2020:2024)search_by_year(2020:2024)
Search the Political Science Replication Index
search_replications( query = NULL, journal = NULL, method = NULL, data_type = NULL, year = NULL )search_replications( query = NULL, journal = NULL, method = NULL, data_type = NULL, year = NULL )
query |
Optional free-text search term, matched case-insensitively against each record's title, description, and author names. |
journal |
Optional character vector of journal short codes (see
|
method |
Optional character vector of method tags to filter to; a record matches if it has at least one of the given tags. |
data_type |
Optional character vector of data-type tags; same
matching rule as |
year |
Optional integer vector of publication years (e.g. |
A tibble::tibble() of matching records, with one row per
replication package and columns journal_short, title, doi, url,
authors (a single "Last, First; Last, First" string), year,
description, method_tags, data_type_tags.
search_replications(query = "regression discontinuity", journal = "AJPS") search_replications(method = "Survey Experiment", year = 2020:2024)search_replications(query = "regression discontinuity", journal = "AJPS") search_replications(method = "Survey Experiment", year = 2020:2024)