dgrtwo / tidy-text-mining

Manuscript of the book "Tidy Text Mining with R" by Julia Silge and David Robinson
http://tidytextmining.com
Other
1.32k stars 806 forks source link

Broken code in 9.1 #67

Closed arencambre closed 5 years ago

arencambre commented 5 years ago

This code in section 9.1 cannot work:

raw_text <- tibble(folder = dir(training_folder, full.names = TRUE)) %>%
  unnest(map(folder, read_folder)) %>%
  transmute(newsgroup = basename(folder), id, text)

unnest expects a data frame for its data argument (source), and map returns a list (source).

Anyone using the code will get this error: Error: map(.$folder, read_folder) must evaluate to column positions or names, not a list.

Also, unnest requires specification of the cols argument, and that is not specified in the code.

juliasilge commented 5 years ago

Thank you so much for the report @arencambre! 🙌 This code I just pushed should fix the issue.

arencambre commented 5 years ago

Ah, breaking change in tidyr! I was wondering what the root cause was. 😁