Skip to content

Small improvements in the austen_books function? #13

Description

@rdstern

@juliasilge I really like the janeaustenr package, so many thanks.

I am using it as an example to show that starting with a little "neat" R is often useful. I have 2 small suggestions:

a) The current version includes the library(dplyr) line, but there is no library(janeaustenr) line. Please could this be added.
b) Your book includes an even "tidier" version with four variables. Very nice. Could you include this function instead - or maybe as well? It is easy to copy from the book, but even easier if it could be included in the package.

library(janeaustenr)
library(dplyr)
library(stringr)

original_books <- austen_books() %>%
  group_by(book) %>%
  mutate(linenumber = row_number(),
         chapter = cumsum(str_detect(text, 
                                     regex("^chapter [\\divxlc]",
                                           ignore_case = TRUE)))) %>%
  ungroup()

Happy New Year

Roger

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions