This bookdown book is a work in progress. We'll update this README
and the repo status when ready! 🚀
Install the required packages.
Here's one way to install the needed packages (only the ones that you don't already have) using the pak package.
pkg_list <- c("bookdown", "devtools", "dichromat", "DT", "fs", "gapminder",
"gender", "geonames", "git2r", "glue", "gridExtra", "htmltools",
"httr", "knitr", "RColorBrewer", "rebird", "rmarkdown", "rplos",
"rvest", "testthat", "tidyverse", "usethis", "viridis", "xfun",
"xml2", "ropensci/genderdata", "rstudio/gt", "rstudio/renv")
# install.packages("pak")
pak::pkg_install(pkg_list)
Another option is to use the renv package to replicate our exact project library. renv is a package that uses a snapshot and restore strategy to create reproducible envnvironments for R projects. renv will create a private, project-specific library that is separate from your personal library of packages. This would be a good option if, for example, you have another project that relies on a specific version of a package and you don't want to mess with it by upgrading, downgrading, etc.
If you want to learn more about what renv is doing behind the scenes checkout renv's main site.
Note: The renv package is still in under active development, so please open an issue here if these instructions seem out of date.
Once you have a local copy of this project (either via fork and clone or by downloading this repository as a ZIP file), follow these steps:
-
Install the renv package (not on CRAN yet).
# install.packages("devtools") devtools::install_github("rstudio/renv")
-
Run
renv::init(bare = TRUE)
in the Console.- This will create a private, project-specific library. The
bare = TRUE
argument tells renv that it should not try to add anything to this new library yet. If you take a took at the Packages tab in RStudio there will be two headers: "Packrat Library" and "System Library". The only package listed under "Packrat Library" (i.e. the private, project-specific library) will be renv.
- This will create a private, project-specific library. The
-
Run
renv::restore()
in the Console.- This will print out "The following package(s) will be installed" followed by a long list of packages. Respond yes. renv will install the packages by copying them over from the cache in the
renv/
folder.
- This will print out "The following package(s) will be installed" followed by a long list of packages. Respond yes. renv will install the packages by copying them over from the cache in the
-
Restart R (Session > Restart R)
- If you take a look at the Packages tab, there should be a lot more packages listed under "Packrat Library" now.
-
You should now be able to render the bookdown locally via either
bookdown::serve_book()
or Addins > Preview Book.
One file, 37_diy-web-data.Rmd, accesses the Open Movie Database API, which requires a key. The site will render without this, without rendering this file. Set up an OMDb key to render this file.
-
Request an API key here.
-
Check your email and follow the instructions to activate your key
-
Add the API key to your
.Renviron
file. First, open your .Renviron
file with the usethis package:library(usethis) edit_r_environ()
Next, add
OMDB_API_KEY=<your-key>
on a new line, replacing<your-key>
with your OMDb key. (Make sure to have your.Renviron
file end on a new line!)