```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


In this lab you can use the interactive console to explore or **Knit** the document. 
Remember anything you type here can be "sent" to the console with Cmd-Enter (OS-X) or Ctrl-Enter (Windows/Linux) in an R code chunk.


# Part 1

1\. Create a new object called `my.num` that contains 6 numbers.

```
# General format
my.num <- c(number1, number2, ...)
```

```{r}
my.num <- c(5, 4, 7, 8, 12, 14) # These can be any real numbers
```


2\. Multiply `my.num` by 4.

```{r}
my.num * 4
```


3\. Create a second object called `my.char` that contains 5 character strings.

```
# General format
my.char <- c("character1", "character2", ...)
```

```{r}
my.char <- c("banana", "garlic", "pickles", "hot chocolate", "7-Up") # Again,these can be anything
```


4\. Combine the two objects `my.num` and `my.char` into an object called `both`.

```{r}
both <- c(my.num, my.char)
```


5\. What is the length of `both`? Use the `length()` function.

```{r}
length(both)
```


6\. What class is `both`?

```{r}
class(both)
```


**Bonus / Extra practice**: Create a vector that contains 4 sets of the numbers 1, 2, 3, and 4.

```{r}
vec_1 <- c(1, 2, 3, 4)
vec_2 <- c(vec_1, vec_1, vec_1, vec_1)
```


# Part 2

7\. Divide `both` by 3, what happens?

```{r, error=TRUE}
both / 3
```


8\. Create a vector with elements 1, 2, 3, 4, 5 and call it `x`.

```
# General format
x <- c(...)
```
 
```{r}
x <- c(1, 2, 3, 4, 5)
```


9\. Create another vector with elements 10, 20, 30, 40, 50 and call it `y`.

```
# General format
y <- c(...)
```

```{r}
y <- c(10, 20, 30, 40, 50)
```


10\. Determine the length of `x` and `y`. Next, add them together.

```{r}
length(x)
length(y)
x + y
# [1] 11 22 33 44 55
```


11\. Append the value 60 onto the vector `y` (hint: you can use the `c()` function).

```
# General format
y <- c(y, ...)
```

```{r}
y <- c(y, 60)
```


12\. Determine the length of `x` and `y`.

```{r}
length(x)
length(y)
```


13\. Add `x` and `y` together. What happens?

```{r}
x + y
# [1] 11 22 33 44 55 61
# Warning message:
# In x + y : longer object length is not a multiple of shorter object length
# R "auto replicates" the shorter vector when the vectors aren't the same length - this is not what we want!
# In this case, it reads x as c(1, 2, 3, 4, 5, 1)!
```


**Bonus / Extra practice**: Multiply the following `a` and `b` together. How is this similar to the way R performs addition in #10 ?

```{r}
a <- c(1, 2, 3)
b <- c(10, 100, 1000)
a * b
# R adds together the first element of each vector, then the second, and so on. This order also applies when multiplying!
```


14\. Practice loading the `tidyverse` package. Remember you will need to install it if you haven't already.

```
# General format
library(...)
```

```{r}
# install.packages("tidyverse")
library(tidyverse)
```


15\. There is a function inside the tidyverse called `count()`. Open up the help page about `count()` using a `?`. What is the title of the help page?

```
# General format
?function
```

```{r}
?count
# Count the observations in each group
```

