Skip to content

rstudio-education/stat545

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Creative Commons License

This bookdown book is a work in progress. We'll update this README and the repo status when ready! 🚀

Requirements to preview the site locally

Install the required packages.

Option 1: Use renv for a project-specific library

This is how we work locally and on Travis-CI, where the public product is actually built and deployed.

The renv package uses a snapshot and restore strategy to create reproducible envvironments for R projects. A project that uses renv has its own project-specific library that is separate from your personal library of packages. This helps contributors ensure we're all using the same version of packages and that the public site is also being built from these versions.

  1. Get a local copy of the website source.
    • Users of devtools/usethis can do:
      usethis::create_from_github("rstudio-education/stat545")
      Note that usethis::create_from_github() works best when it can find a GitHub personal access token and usethis (git2r, really) is configured correctly for your preferred transport protocol (SSH vs HTTPS). Setup advice.
    • Otherwise, use your favorite method to fork and clone or download the repo as a ZIP file and unpack.
  2. Start R in your new stat545/ directory. Expect to see some renv startup along these lines:
    Failed to find installation of renv -- attempting to bootstrap...
    * Downloading renv 0.7.0-50 ... Done!
    * Installing renv 0.7.0-50 ... Done!
    Successfully installed and loaded renv 0.7.0-50.
    * Project '~/tmp/stat545' loaded. [renv 0.7.0-50]
    
  3. Run renv::restore(). This will print out "The following package(s) will be installed" followed by a long list of packages. Respond "yes". renv will build the project-specific library containing packages at the correct versions.
  4. You should now be able to render the site in all the usual ways for bookdown, such as bookdown::render_book() or Addins > Preview Book.

Option 2: Use pak or similar

If the renv infrastructure is confusing to you, use renv::deactivate() to remove it. You could then use your favorite method of package installation to make sure you've got the necessary packages (although there's no guarantee that you're using the same version as we are).

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")

# install.packages("pak")
pak::pkg_install(pkg_list)

This is nice because it can install from CRAN and, in the case of packages like rstudio/gt, also from GitHub.

Note: the package list above is currently static, so consider that it may not be up to date.

OMDb API key

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.

  1. Request an API key here.

  2. Check your email and follow the instructions to activate your key

  3. 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!)

About

A 📖 on data wrangling, exploration, & analysis with R - created by Jenny Bryan, made with bookdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages