This package contains exercises for getting started with the programming
language R. They were designed to align with the courses I am teaching at the
Europa-University Flensburg, but the material they cover is most likely part of
many introductions to R.
You need two things installed on your computer:
Everything below is typed into the console in RStudio, the pane with the
> prompt.
Copy the following two lines into the console and press enter:
install.packages("DataScienceExercises",
repos = c("https://teaching-datascience.r-universe.dev",
"https://cloud.r-project.org"))
This installs the package together with everything it needs. It may take a few minutes the first time.
To check that everything worked:
DataScienceExercises::check_setup()
The exercises are part of the package, so corrections and new exercises only
reach you when you install it again. If an exercise behaves strangely, run the
same two lines from above once more - this updates the package. The version you
have is shown by packageVersion("DataScienceExercises").
To see which exercises are available:
library(DataScienceExercises)
list_exercises()
To start one of them:
run_exercise("Basics")
The exercise opens in your web browser. The first start of an exercise takes a while (often a minute or more) because it has to be prepared for you - this is normal, please be patient. Later starts are much faster.
To stop an exercise, click the red stop button in RStudio, or click into the
console and press Esc.
| Exercise code | Description |
|---|---|
| Basics | Exercises on how to conduct basic tasks in R |
| Functions | Exercises on how to define your own functions |
| ObjectTypes1 | Exercises on how to handle basic object types |
| ObjectTypes2 | Exercises on how to use advanced object types, such as data frames, tibbles or factors |
| Visualization1 | Building plots using ggplot2 |
| ProjectOrga | How to set up an R project and use the here function |
| ImportData | How to import data, especially csv files using data.table::fread()
|
| RMarkdown | An older version that contains some exercises on R Markdown |
| Quarto | A newer version that contains some exercises on Quarto |
| Wrangling1 | The basics of manipulating and reshaping data frames |
| Wrangling2 | More exercises on making data wider or longer |
| LinearRegression1 | Basics of linear regression models |
| LinearRegression2 | More advanced applications for linear regression models |
| Sampling | Simulating random processes and conduct Monte Carlo simulations |
| Models | Multiple choice questions on the theory of models |
Run DataScienceExercises::check_setup() first. It prints your R version and
tells you whether any package is missing. Send its output to your lecturer if
you need help - it contains everything needed to understand the problem.
Warnings are not errors. While an exercise is being prepared, R often prints
lines starting with Warning or [WARNING], for example about deprecated
pandoc options. These come from the packages working in the background, not
from your code, and you can ignore them. Only a message starting with Error
actually stops something from working.
Some common situations:
list_exercises().
run_exercise() ignores capitalisation and suggests the closest match.If the installation above does not work, you can install directly from GitHub.
This route needs the remotes package first, and is slower:
install.packages("remotes")
remotes::install_github(
repo = "teaching-datascience/DataScienceExercises",
upgrade = "never")
The upgrade = "never" matters: without it you are asked which of your other
packages to update, and answering "all" can start lengthy installations that
may fail.
For bug reports and feedback please use the Github issue tracker.