Created
November 6, 2017 23:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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