Data Visualisation and Analysis

Download course materials from here.

Base R functionality

Dataset sleep:

head(sleep)
  • column 1 = how many extra hours of sleep were recorded
  • column 2 = which drug was administered
  • column 3 = which participant

Indices, or: finding the index of the value you want

What does this do?

sleep[1,]

How does this differ from [1,]?

sleep[2,] # so that means this is row 2

How does this differ from [3,]?

sleep[,3] # what do you think this is? (column 3)

…which makes it dataset[row,column]

More descriptive methods

You can also navigate with column names:

How would you view the column extra?

Use str() to get a summary of the structure of the dataset

What are all the unique values in ID?

What’s the value in the first row, third column?

What’s the first element in the column ID?

You can also view the dataset as a spreadsheet (although it can’t be altered).

View(sleep)

Tidyverse functionality

library(tidyverse)

A tibble is different from a table.

Pipes are like toy funnels