Building a Book

Building a Book
Author

Muxin Hua

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.

I got the word pseudo-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.)

I got most of the problem of package not found, so the most reasonable way to do is install these packages, for the most of time, it worked well.
However, there were two problems took more efforts.
The first one is Error in if (c(TRUE, FALSE)) 1 : the condition has length > 1 Calls: local … withVisible -> eval_with_user_handlers -> eval -> eval. This Error was very specific that this is an error came from the file Control-flow.Rmd. I went straight to this file and spotted the chunk raising the error. I noticed the chunks nearby have similar code expect they specified Error = TRUE. I tried to add this command to the chunk and it just worked! The second peoblem was more tricky. I got dev.control() called without an open graphics device https://github.com/brentthorne/posterdown/issues/42. There was also some complaining about emo not installed. I was trying to solve it by installing it. Turned out there was no matching library for R version. I searched google to find I should install things from github. But the trickt part is that devtool should be the ideal way to do that, but my R wouldn’t let me to do so and kept asking me to restart R session. Eventually this is solved by installing and running remotes with rejecting R session restart request.

Submit to your repo and you are done!