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:
- Clone the repository
https://github.com/hadley/adv-r
. - Open the R project in the repository in RStudio.
- Activate the
Build
tab (by default in the top right panel). Click on theBuild Book
button. - 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.
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.
No.
- 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)
I can not compile the book in blog 3. The error I get is caused by line 106 of Control-flow.Rmd.
In Control-flow.Rmd, the author demonstrates what are the invalid inputs to an if
statement. We know usually the condition should be a single TRUE
or FALSE
. But there is an exception:
In line 101, the author sets Sys.setenv("_R_CHECK_LENGTH_1_CONDITION_" = "false")
to allow an if statement to take a condition more than length 1. I run Sys.getenv()
to make sure _R_CHECK_LENGTH_1_CONDITION_
is indeed set to "false"
.
In line 106, the author writes if (c(TRUE, FALSE)) 1
and says this should generate a warning message but not an error. However, now R generates an error “the condition has length > 1” and does not compile Control-flow.Rmd, and therefore fail to compile the book.
- 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).
I added error = TRUE
in the chunk options so the compilation does not stop at error so the book can be built.
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.)
Another big problem I have is a .sty file is missing for Latex. By clicking on “Build Book” button, the default output is a pdf file. Later I found index.Rmd file and knitted it into index.html.
Submit to your repo and you are done!