Drawning in ERRORS

Building a Book
Author

Motina

Published

February 9, 2023

Prompt:

The goal of this week’s blog is to document what you are doing when things do not go according to plan.

Similar to previous exercises, we have a specific use case in mind: we want to build a book from a github repository.

What happens in practice usually, is that we run into some problems. So your real task turns into that of a bug-hunter and fixer. Luckily, you have a community (the class discussion board) who might be able to help you.

What we want: build a book

Build the html version of the 2nd edition for Hadley Wickham’s book Advanced R Programming from a github repository.

Steps:

  1. Clone the repository https://github.com/hadley/adv-r.
  2. Open the R project in the repository in RStudio.
  3. Activate the Build tab (by default in the top right panel). Click on the Build Book button.
  4. The book will be available in html format as index.html

Deliverable (1): what is the last word in chapter 15? - You don’t have to answer this question, if things don’t work.

It took forever to compile, but I finally got the HTML version to work!

The last word in chapter 15? CLASS! IT IS CLASS!

What to do when things don’t work?

Errors happen, they are frustrating, but if we learn something from them, we can turn them into valuable experiences.

  • check the Questions and Answers forum in Canvas whether there is a solution available for your problem.

  • if the above document does (not yet) include your question, document the error you encounter (be as concise and specific as you can at the same time)

  • if the Question and Answers forum does (not yet) include a solution, describe one approach on how you tried to solve the problem (and how this did not work).

  • submit the description of your problem in Canvas at Discussions > Questions and Answers. Write the paragraph in the mindset that you want to get help from somebody, and you try to describe the problem you are encountering.

  • Extra points (1 pt for the first suggested working solution): post a solution to one of the problems in the Questions and Answers forum (your own does not count!).

Deliverable (2): Write a paragraph on the biggest problem you encountered when you were building the book, (and how you managed to solve it.)

  • Building the book has been a pain! :))

  • The first error I got was “Failed to load Cairo DLL” in R, which is because I use. MacOS. According to CRAN, it’s related to XQuartz since it’s not part of OS X anymore. I installed XQuartz and basically all Cairo problems are fixed.

  • The next error was object ‘wrap’ not found!

  • I fixed the error by changing “wrap” to “sew” in the registerS3method() function in common.R.

  • In the meantime, I installed a bunch of packages to get going! :))

  • After that, I get to a big one! Error in if (c(TRUE, FALSE)) 1 : the condition has length > 1

  • It turns out the behavior described is now the default (as of R 4.2.0).In other words, the command “if (c(TRUE, FALSE)) 1” will fail no matter what condition is set. To fix this, I just set error=TRUE in the addressed code chunk!

  • Again, there was a bunch of missing packages! :))

  • At this point it was taking almost 15-20 minutes to compile the book, and I ended up getting an error saying **LaTeX failed to compile _main.tex.**

  • I tried updating tinytex, but I got the same error! I installed tlmgr to install packages, but it didn’t work! As I write this I’m trying options(tinytex.verbose = TRUE) to see if it fixes the error. I’ll let you know how it goes!

. . . .

  • Hey, it’s been a while! My PDF version wouldn’t compile, but I made it work with HTML! I’m still trying to fix the LaTex error! :)

You can write your experience directly into the README.Rmd file. Just make sure that you change the yaml at the top: change the author at the top, and give your post a new title (don’t change the category :))

Commit and push to your repo and you are done!