Introduction to R

This tutorial points to some of the best R tutorials on the internet and provides some sample tasks to test your learning.

It is strongly encouraged to use RStudio when learning R. Installation instructions for R and RStudio can be found at this link.

Learning outcomes

  • Install and launch R and RStudio
  • Execute basic commands such as variable assignments and arithmetic operations
  • Install packages inside of R/RStudio
  • Create and modify data structrues and tables
  • Navigate and undertake basic operations on R data frames

Approximate time to finish tutorial

  • Intro to R tutorials: 6 hours each (only necessary to complete one)
  • Additional tasks: 1 hour
  • Pre/post surveys: 10 minutes

Order of tutorial

Please do the pre-learning quiz, then select a linked tutorial to complete.
Once finished the tutorial, take the post-learing quiz.

Intro to R Pre-tutorial Survey

Introduction to R tutorials

Intro to R Post-tutorial Survey

Bioinformatics/data science focussed tutorials (some are advanced)

Example tasks

A set of example tasks can be found on the W3 resource webpage

Task 1

Create a dataframe comprised of 3 rows and 3 columns
Place a random number between 1 and 100 in each element of each row
Create a new column named Sum at the end of the dataframe
For each row, add up all elements in that row and place the sum of the elements in the column Sum in that row
Create a new row
For each column get the minimum value in that column and store it in the new row, in that column index

Task 2

Create a data frame with 3 columns named "Sample 1" "Sample 2" "Sample 3" and 3 rows
Fill the elements in each row with random numbers between 1 and 50
Swap the columns to be in the order "Sample 3" "Sample 2" "Sample 1"
Sort the matrix by ascending order of the values in column 1