Fixes for Known Issues

While writing this book, we anticipated issues cropping up in the printed code. The systems our workflows rely on are in constant flux. Developers are updating their packages, websites administrators may change urls, and of course, we may have made errors (we are only human). So, we agreed we should maintain this website to offer fixes to any issues. If you run into such issues, please let us know! You can use the feedback form or email us directly. We also re-run the code quarterly to detect any problems.

Below, are error or warning messages that might print in your R console, and a link to a potential solution.


Chapter 3: Computing Basics

unexpected string constant in
Yes, there is a minor but consequential typo in the code to install all the `R` packages. It is a misplaced comma (p. 28). This results in the error message: `unexpected string constant in`. Below is the corrected code block:

cran_pkgs <- c(
"backbone", "caret", "factoextra", "gender", "ggpubr", "ggraph", 
"ggrepel", "ggtern", "glmnet", "gmodels", "googleLanguageR",
"guardianapi", "gutenbergr", "hunspell", "igraph", "irr", 
"lexicon", "lsa", "marginaleffects","Matrix", "network", "proustr", 
"qdapDictionaries", "quanteda", "quanteda.textmodels", "remotes", 
"reshape2", "reticulate", "rsample", "rsvd", "rtrek", 
"semgram", "sentimentr", "sna",  "stm", "stminsights", 
"stringi",  "tesseract", "text2map",  "text2vec", "textclean", 
"textstem", "tidygraph", "tidymodels", "tidyquant", "tidytext", 
"tidyverse", "tokenizers", "topicdoc", "topicmodels", "udpipe"
)

install.packages(cran_pkgs)

Chapter 7: Wrangling Words

Could not download a book

In Chapter 7 (p. 113), when trying to download Lewis Carroll’s book from Project Gutenberg:

book_ids <- c(11, 12, 13, 620, 651)
my_mirror <- "http://mirrors.xmission.com/gutenberg/"

carroll <- gutenberg_download(book_ids,
                              meta_fields = "title",
                              mirror = my_mirror)

You may see the following:


Warning message:                                                                                                                                                                                                                      
! Could not download a book at http://mirrors.xmission.com/gutenberg//1/11/11.zip.
ℹ The book may have been archived.
ℹ Alternatively, You may need to select a different mirror.
→ See https://www.gutenberg.org/MIRRORS.ALL for options. 

The solution is in the message. Go to https://www.gutenberg.org/MIRRORS.ALL and select a different mirror. For example:


my_mirror <- "https://gutenberg.pglaf.org/"

Chapter 8: Tagging Words

No spaCy environment found
In Chapter 8 (p. 143) after running:
spacy_initialize(model = "en_core_web_sm", condaenv = "myenv") 

You may see the error message:

No spaCy environment found. Use `spacy_install()` to get started.

Luckily, running spacy_install() – as the spacyr package message states – does appear to resolve the issue!

From inspecting the spacyr package further, it seems that spacy_initialize() no longer takes the condaenv argument (i.e. it is deprecated). This is why it cannot find the Python package spacy that we installed during our setup (in Chapter 3, p. 29).