---
title: "Data Wrangling R with Answers"
author: "Prof. Eric A. Suess"
format:
  html:
    self-contained: true
---

Some of the code from Chapter 4 and 5.

In this chapter dplyr is introduced.  We will be using dplyr all year.

The main idea of data wrangling with dplyr are the 5 verbs. 

**select()**  # take a subset of columns

**filter()**  # take a subset of rows

**mutate()**  # add or modify existing columns

**arrange()**  # sort the rows

**summarize()**  # aggregate the data across rows

The dplyr package is part of the tidyverse.  We will install and load the tidyverse.

```{r message=FALSE}
library(mdsr)
library(tidyverse)
```

# Star Wars dataset

```{r}
data("starwars")
glimpse(starwars)
```

# select()

```{r}
starwars %>% select(name, species)
```