6 learnr activities
6.1 Setting up
We’re going to embed some learnr activities now. The first one is “live” on the shinyapps.io server. It will walk you through setting up and running the other later tasks.
To do this, You’re going to download RStudio (if you haven’t already). Follow the tutorial below to do that.
#knitr::include_url("https://learnr-examples.shinyapps.io/ex-setup-r/")
knitr::include_app("https://learnr-examples.shinyapps.io/ex-setup-r/", height = "600px")6.2 Downloading the resources
6.2.1 Getting the files
Ok, now we’re going to download these files from github, and run something.
The code for this book is available at https://github.com/sjgknight/dsi/ You can download a set of interactive tutorials from https://github.com/sjgknight/learnr most of these were built by the great RStudio team and collaborators.
There are three ways you can get the code:
The easiest: Go to that repository, on the right hand side you’ll see “code” - click that, and “download zip” (or, direct link)
Medium level: You can do the same thing using
R. Now you’ve gotRinstalled, you can run the code below to do this.Git-method: If you’re using git anyway (or, going to learn in Stats, Data Science Practice, or another subject) you might like to link the project to the repo, there are instructions for that at Happy Git and GitHub for the useR.
download.file(url = "https://github.com/sjgknight/learnr/archive/refs/heads/master.zip", destfile = "dsi-learnr.zip") #if you want the book too, you can uncomment this line
# unzip the .zip file
unzip(zipfile = "dsi-learnr.zip")6.2.2 Creating and opening projects
RStudio helps you manage projects. Make sure the download is unzipped in a location you want it on your machine:
- If you’ve downloaded an existing project, you might find the .Rproj file, and click that
- Now you’re inside a project. Projects help you organise your work. They are associated with directories and their subdirectories. You can create new ones under the ‘File’ menu.
- Now you’ve opened the project, go to the instructions Rmd, open it, and follow along from there