View source: R/get_gutenberg_data.R
get_gutenberg_data | R Documentation |
Retrieves works from Project Gutenberg based on specified criteria and saves the data to a CSV file. This function is a wrapper for the gutenbergr package.
get_gutenberg_data(
target_dir,
lcc_subject,
birth_year = NULL,
death_year = NULL,
n_works = 100,
force = FALSE,
confirmed = FALSE
)
target_dir |
The directory where the CSV file will be saved. |
lcc_subject |
A character vector specifying the Library of Congress Classification (LCC) subjects to filter the works. |
birth_year |
An optional integer specifying the minimum birth year of authors to include. |
death_year |
An optional integer specifying the maximum death year of authors to include. |
n_works |
An integer specifying the number of works to retrieve. Default is 100. |
force |
A logical value indicating whether to overwrite existing data if it already exists. |
confirmed |
If |
This function retrieves Gutenberg works based on the specified LCC subjects and optional author birth and death years. It checks if the data already exists in the target directory and provides an option to overwrite it. The function also creates the target directory if it doesn't exist. If the number of works is greater than 1000 and the 'confirmed' parameter is not set to TRUE, it prompts the user for confirmation. The retrieved works are filtered based on public domain rights in the USA and availability of text. The resulting works are downloaded and saved as a CSV file in the target directory.
For more information on Library of Congress Classification (LCC) subjects, refer to the Library of Congress Classification Guide.
A message indicating whether the data was acquired or already existed on disk, writes the data files to disk in the specified target directory.
## Not run:
data_dir <- file.path(tempdir(), "data")
get_gutenberg_data(
target_dir = data_dir,
lcc_subject = "JC"
n_works = 5,
confirmed = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.