I am trying to make a plot the Word Count of each chapter and verse in the Book of Mormon (a religious book structured similarly to the Bible). I've set the word count of each chapter as the y-variable. For the X-axis, I've created the labels and ordered the books by their respective chapters in the Book of Mormon (for example, 1 Nephi is actually the first section of the Book of Mormon and Moroni is the actually last section in the Book of Mormon).
The problem is that I want to separate the chapters as well. For example, 1 Nephi has 27 chapters, and I would like there to be some ordering according to the chapter number as well. This seems like a tricky problem since each book has a different number of chapters.
I'm curious how others think I might be able to approach this. Here is the code I have so have so far.
To be clear, I'm trying to spread out the data on the x-axis by also factoring by the chapter number along with the book number.
BookOrdering <- c("1 Nephi", "2 Nephi", "Jacob", "Enos", "Jarom", "Omni", "Words of Mormon", "Mosiah", "Alma","Helaman","3 Nephi","4 Nephi", "Mormon", "Ether", "Moroni")
BoM %>%
mutate(book_title = factor(book_title, levels = BookOrdering)) %>%
ggplot(aes(y = lengths(gregexpr("\\W+", scripture_text)) + 1, x = book_title)) +
labs(x="Book (ordered by position in the Book of Mormon)", y="Words in Chapter") +
geom_point()