Skip to content

Instantly share code, notes, and snippets.

@erikgregorywebb
Created October 21, 2020 18:33
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 erikgregorywebb/72447acecae2a62f37bd5cf07396c684 to your computer and use it in GitHub Desktop.
Save erikgregorywebb/72447acecae2a62f37bd5cf07396c684 to your computer and use it in GitHub Desktop.
# import libraries
library(scriptuRs)
library(tidyverse)
# get scripture
bible = scriptuRs::kjv_bible()
# roll up by chapter
bible_chapters = bible %>%
mutate(verse = paste(verse_number, '', text, '\n\n')) %>%
group_by(volume_id, volume_long_title, book_title, book_id, chapter_number, chapter_id) %>%
summarize(verses = str_c(verse, collapse = "")) %>%
arrange(volume_id, book_id, chapter_id) %>%
select(volume_id, volume_long_title, book_title, book_id, chapter_number, chapter_id, verses)
# roll up by book
bible_books = bible_chapters %>%
mutate(chapter = paste('Chapter ', chapter_number, '\n', verses, sep = '')) %>%
group_by(volume_id, volume_long_title, book_title, book_id) %>%
summarize(chapters = str_c(chapter, collapse = "")) %>%
arrange(volume_id, book_id)
# export
write_csv(bible, 'kjv-bible.csv')
write_csv(bible_chapters, 'bible_chapters_v3.csv')
write_csv(bible_books, 'bible_books.csv')
bible_chapters %>% group_by(book_title) %>% count(sort = T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment