Last active
May 28, 2024 23:51
-
-
Save dshemetov/44616e9b2ffd3659a416486c26374b8b to your computer and use it in GitHub Desktop.
R setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you need to, install R by visiting CRAN (https://cran.r-project.org/) and | |
# downloading the appropriate version for your operating system. | |
# Create a project folder `delphi_project` and open it. | |
# Open an R terminal and install the renv, pak, and rspm packages by running the | |
# commands below. | |
# * The pak package is the modern installer for R packages. Learn more at | |
# https://pak.r-lib.org/. | |
# * The rspm package is a package manager for R that allows you to install | |
# packages from the RStudio Package Manager (RSPM), where you can find | |
# precompiled packages for Linux (you can ignore this if you're not on Linux). | |
# This dramatically speeds up package installation time. Learn more at | |
# https://cran4linux.github.io/rspm/. | |
# * The renv package is a package manager for R that allows you to create a | |
# project-specific library of packages. This ensures that your project is | |
# reproducible and that you can share your project with others without | |
# worrying about package versions. Learn more at | |
# https://rstudio.github.io/renv/. | |
install.packages( | |
"pak", | |
repos = sprintf( | |
"https://r-lib.github.io/p/pak/stable/%s/%s/%s", | |
.Platform$pkgType, R.Version()$os, R.Version()$arch | |
) | |
) | |
pak::pkg_install(c("rspm", "renv")) | |
# Run the following code to initialize the renv package. | |
renv::init() | |
# Create a new file in the project folder called `.Rprofile` and add the | |
# following lines to it. | |
source("renv/activate.R") | |
# Ignore the following line if you're not on Linux. | |
rspm::enable() | |
# Restart the R session and now type the following code to install the | |
# dependencies for the project. | |
pak::pkg_install(c("epidatr", "cmu-delphi/epiprocess", "cmu-delphi/epipredict")) | |
# After a few minutes, you should now have all the dependencies needed to start | |
# working with the packages. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment