Follow these steps to install everything on your own computer (for offline use). Alternatively, get started quicker by Using RStudio Cloud.
Download and install the latest version of R from:
https://www.stats.bris.ac.uk/R/
Windows: Download R for Windows
- base
- Download R 3.6.0 for Windows
Mac: Download R for (Mac) OS X
- R-3.6.0.pkg
Then download and install RStudio:
https://www.rstudio.com/products/rstudio/download/#download
Windows: RStudio 1.2.1335 - Windows 7+
Mac: RStudio 1.2.1335 - Mac OS X 10.12+ (64-bit)
healthyr_notebooks = c("tidyverse", "boot", "finalfit", "flexdashboard",
"gapminder", "here", "kableExtra", "knitr", "remotes",
"rmarkdown", "shiny", "survminer", "tinytex")
install.packages(healthyr_notebooks)
remotes::install_github("thomasp85/patchwork")
tinytex::install_tinytex()
If it asks you "Do you want to restart your R session", press Yes the first time. If it immediately asks again, press No.
Code to check tinyTex and Tex working as expected:
tinytex:::is_tinytex()
# If installed should return `TRUE`.
# Notice the triple colon, this is because it's an internal variable name.
-
~"can't find remotes": try doing step 3.2 (restart) again. We only just installed
remotes::
in 3.1 so RStudio needs a restart before we can start using it. -
~"TeX failed, you already have a TeX distribution...". If you already have LaTex installed on your computer, the
tinytex::install_tinytex()
one is not necessary and might not work. This is fine, there is no harm in copy-pasting in anyway if you are not sure.
- Click on
Clone or download
thenDownload ZIP
(top-right of this GitHub page) - Unzip the folder and rename it to just healthyr (so from
healthyr_notebooks_materials-master
tohealthyr
). - Move this folder to where you will be keeping your R projects. Each RStudio project is in a separate folder, but you can always move them afterwards (e.g. into a new folder called R-projects).
- Open RStudio. Click on New Project.
- Select "Existing Directory".
- Browse to find your
healthyr
folder, thenCreate Project
. - Click on the
01_introduction
folder in the Files pane (bottom-right), then open01_introduction.Rmd
.
RStudio cloud is a free online platform for learning R. It saves you from installing R and RStudio yourself, but it does mean you need an internet connection to access it via a web browser.
- Create an account on RStudio cloud (these replace steps 1. and 2. from Getting Started).
- Go to "Your workspace"
- Click on the selection arrow next to "New project" and select "New Project from Git Repo" (this reaplaces step 4. of Getting started)
- After the project has loaded, copy-paste the lines below into the Console and press Enter:
healthyr_notebooks = c("tidyverse", "boot", "finalfit", "flexdashboard",
"gapminder", "here", "kableExtra", "knitr", "remotes", "rmarkdown",
"shiny", "survminer", "tinytex")
install.packages(healthyr_notebooks)
- Then Restart R (top menu Session - Restart R) to then run this line (same as before, copy-paste to the Console):
remotes::install_github("thomasp85/patchwork")
- Click on the
01_introduction
folder in the Files pane (bottom-right), then open01_introduction.Rmd
.
If you want to help your friends to learn R, then you can set up a shared space on RStudio Cloud.
- Create a new space (click on
+ New Space
) - Create a new project following the RStudio Cloud instructions 3., 4., 5. from above
- Find "Access" (Settings), set "Who can view this project" to Everyone (default is You, don't worry this is still everyone in the private space)
- Set it as the Base project of this space (https://rstudio.cloud/learn/guide)
- Invite people to join your space - any new projects they create will automatically get the files and packages of the Base project
- After sucefully setting the Base project and testing that a new project has all the files etc you should make your first project private again (Settings, Access, Who can view, You). Otherwise people will get confused and start working directly
- Get in invite to a an RStudio Cloud space where these materials are already set up
- Create an account or Log in with Google or GitHub
- Click on “Join Space”
- Click on “Projects” at the top
- Click on “New Project” and wait while “Deploying project” completes