Guide for Building the R4DS2e Book Locally
Clone Repository
- In the upper right corner of RStudio, click the current project
- Choose
New Project...
- Choose
Version Control
- Choose
Git
- Under
Repository URL:
, enterhttps://github.com/hadley/r4ds
- Under
Project directory name:
, enterr4ds
- Under
Create project as subdirectory of:
uge theBrowse...
-button to navigate to where you want to place this project - Click
Create Project
A Clone Repository
process now starts, wait for it to finish
- In the RStudio
Files
pane of your new project, find and open the fileindex.qmd
- Click the
render
-button above theindex.qmd
-file you just opened - It probably will not run on the first try! Make sure to check the errors, e.g.
Error in library(ggthemes) : there is no package called 'ggthemes'
and then run e.g.install.packages("ggthemes")
- Again, click the
render
-button above theindex.qmd
-file (Be aware that RStudio will show you the file, where the missing package is mentioned, so you will have to make sure, that you click theindex.qmd
-file tab) and redo installation of any missing packages (For Restart R error, see below) - Once all missing packages have been installed, the rendered book will appear in the
Viewer
pane. Click the small white and lightblue icon with and arrow - The book will now open locally in your browser on e.g.
http://localhost:7829/index.html
Congratulations! You have now sucessfully cloned a GitHub repository and build an entire Quarto book from scratch!
If you get stuck in a loop where RStudio says “Restart R prior to install” on the same package. Select Cancel
, quit the project, re-open the project and as the first thing, type in the install.packages("PACKAGE_NAME")
-command and then select No
, when it prompts for restart.
Stop for a moment and consider that you get all of this is for free! All the tons of hours being put in by the 287 contributors have done so in the name of open source and open learning! That’s nothing short of awesome!