Skip to content

Instantly share code, notes, and snippets.

@rer145
Created November 6, 2017 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rer145/81fcc3733b6847b224091cef51a30924 to your computer and use it in GitHub Desktop.
Save rer145/81fcc3733b6847b224091cef51a30924 to your computer and use it in GitHub Desktop.
How to download the text of a novel from Project Gutenberg with R
library(gutenbergr)
library(stringr)
# search for the EXACT name of the novel title
gutenberg_works(title=='Dracula')
# search for the EXACT author's name (Last Name, First Name)
gutenberg_works(author=='Stoker, Bram')
# search for the word 'Frankenstein' in the title column
gutenberg_works(str_detect(title, 'Frankenstein'))
# search for part of an author's name
gutenberg_works(str_detect(author, 'Stevenson'))
# Once you have searched and found the novel you want, make note of the gutenberg_id field
# Downloading Dracula (gutenberg_id = 345
dracula<-gutenberg_download(345)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment