---
title: 'Exercise 01: MSc Data Skills Course'
author: "Psychology, University of Glasgow"
output: html_document
---

```{r setup, include=FALSE}
# please do not alter this code chunk
knitr::opts_chunk$set(echo = TRUE, message = FALSE, error = TRUE)
```

Edit the code chunks below and knit the document.


## Type commands into the console

In the console, type the following:

```
1 + 2
a <- 1
b <- 2
a + b
```

Look at the Environment tab in the upper right pane. Set the variable `how_many_objects` below to the number of objects listed in the environment.

```{r Q1}
how_many_objects <- NULL
```


## Understand function syntax

Use the `rnorm()` function to generate 10 random values from a normal distribution with a mean of 800 and a standard deviation of 20, and store the resulting vector in the object `random_vals`.

```{r Q2}
random_vals <- NULL
```


Use the help function to figure out what argument you need to set to ignore `NA` values when calculating the mean of `the_values`. Change the function below to store the mean of `the_values` in the variable `the_mean`.

```{r Q3}
the_values <- c(1,1,1,2,3,4,6,8,9,9, NA) # do not alter this line
the_mean   <- NULL
```


Figure out what the function `seq()` does. Use the function to set `tens` to the vector `c(0, 10, 20, 30, 40, 50 ,60, 70 ,80 ,90, 100)`. Set `bins6` to the cutoffs if you wanted to divide the numbers 0 to 100 into 6 bins. For example, dividing 0 to 100 into 4 bins results in the cutoffs `c(0, 25, 50, 75, 100)`,

```{r Q4}
tens  <- NULL
bins6 <- NULL
```


Figure out how to use the `paste()` function to paste together strings with forward slashes ("/") instead of spaces. Use `paste()` to set `my_dir` to "my/project/directory".

```{r Q5}
my_dir <- NULL
```


## Install a package

Install the CRAN package called "fortunes". Run the code to do and include it in the code chunk below, but comment it out. It is bad practice to write a script that installs a package without the user having the option to cancel. Also, some packages take a long time to load, so you won't want to install them every time you run a script.

```{r Q6}
# comment out the installation code

```


The code below has an error and won't run. Fix the code.

```{r Q7}
fortune()
```

## Organise a project

Create a new project called "website".

## Create and compile an Rmarkdown document

In the "website" project, create a new Rmarkdown document called "index.Rmd". Do the following in this document:

* Write a short paragraph describing your research interest. 
* Include a bullet-point list of links to websites that are useful for your research. 
* Add an image of anything relevant.
* Include a code chunk at the end that displays a fortune from the fortunes package. 
* Knit this document to html.