In your first Access lab, we’ll be conducting an experiment in class to test an experiment on memory.

After the lab, we will be writing our first lab report. A lab report has many different sections, which you’ll learn more about in class. One of these sections is our results section.

What goes in our Results section?

In the results section of a lab report, we need to describe to the reader what the results of our experiment were.

In your lab report, you’ll be asked to summarise your findings as well as describe any patterns in your data for the reader.

In a lab report, we summarise our data by calculating descriptive statistics - numbers that help to describe our data (for example, the avergae memory score for a paticular group).

Your Pre-Lab Task

Your pre-lab task is to work through these instructions. The skills you’ll learn in this homework are the same skills we’ll be using in the second week of the labs using the data we’ll collect in the lab.

Preparing to work with R

The first thing we need to do is to download the folder containing the data we’ll be using to practice with in this homework task. Download the folder from Moodle and save this on your computer.

Next, we need to set the working directory in R. This is an instruction to tell R where the folder with the data we want to use is saved on our computers.

To set the working directory follow these steps:

  • Click on ‘Session’ in the R toolbar
  • Go to ‘Set Working Directory’
  • Next, go to ‘Choose directory…’
  • Now find the folder that you downloaded from Moodle with the data

Install tidyverse

R has lots of different packages (sets of tools) we can work with. One of the most popular packages in R (and one you will spend lots of time working with if you continue to undergraduate Psychology) is a package called “tidyverse”.

We need to make sure tidyverse is installed by using the R command install.packages() with the name of the package between the parentheses ().

So, in this case (where our package is called “tidyverse”) we give R the command install.packages("tidyverse")

You only need to install tidyverse once so if you have already done this, skip this step

install.packages("tidyverse")

Loading in tidyverse

We load a package using the R command library() with the name of the package between the parentheses ().

So, in this case (where our package is called “tidyverse”) we give R the command library(tidyverse)

library(tidyverse)

Loading in our data

Now R knows where to find our data (in our working directory) and has loaded in a package (tidyverse) with all the functions we need. Next, we need to load in our data set. To do this we type in the command dat <- read_csv('Access_practice_data.csv')

dat <- read_csv('Access_practice_data.csv')

The command read_csv is telling R we want to read in a ‘csv’ file (like saying .doc or .docx). We have to make sure the file name is typed in exactly the same in R as it is saved on our computer. The arrow <- assigns the data we are reading in our new dame for our data called dat.

Understanding our Data

For this practice session we’ll be looking at some made-up data. In this hypothetical example, we have 10 ‘day’ class Access students and 10 ‘evening’ class access students, amnd we want to compare if there are differences in their final exam grades.

Lets start by looking at our data by typing View(dat)

View(dat)

A new screen will appear showing us our data set. Our data has 20 rows (1 row for each participant) and 3 columns. The first column id gives the participant number. The second column Class tells us if our participant was in the Day and Evening class, and our third column ExamGrade gives us the exam grade (our of 22) for that participant.

Caluclating our Descriptive Statistics

Descriptive statistics are numbers that help to describe our data (for example, the avergae memory score for a paticular group). In this exercise, we want to calculate the average grade for each group of participants, depending on whether they are in the Day or Evening class.

The average can also be referred to as the mean. The mean score is calculated by adding all the score of one group together, and then dividing the total by the number of participants. What to learn more about calculating means? have a look at this website

To calculating the mean exam grade for the day and evening class seperately, we need to first tell R we want to create 2 groups of participants. We do this by using the command group_by() and telling R how we want to group our data.

dat_grouped <- group_by(dat, Class)

The argument ``group_by(dat, Class)``` can be read as “group our data (called dat) by Class”. We now have made 2 groups - one for the day class and one for the evening class.

Now we can calculate the mean (i.e. average) exam score for each group by using the summarise() command.

dat_mean <- summarise(dat_grouped, mean=mean(ExamGrade))

The argument ``summarise(dat_grouped, mean=mean(ExamGrade))``` can be read as “summarise our data (called dat_grouped) by calculating the mean exam grade”. Because we have previously grouped our data, R knows to calculate the mean exam grade for each group

We can check our data by typing View(dat_mean)

`View(dat_mean)

We should now see a table that gives us the mean value for the day class (18.5) and the evening class (14.6).

## # A tibble: 2 x 2
##     Class  mean
##     <chr> <dbl>
## 1     Day  18.5
## 2 Evening  14.6