---
title: "Merging rows"
author: "Jeffrey R. Stevens"
date: "2023-03-03"
output: html_document
execute:
  freeze: auto
---

For these exercises, we'll use the dog breed traits and dog breed popularity rankings data sets. 

1. Load tidyverse, import [`dog_breed_traits_clean.csv`](https://jeffreyrstevens.quarto.pub/dpavir/data/dog_breed_traits_clean.csv) to `traits`, import [`dog_breed_ranks.csv`](https://jeffreyrstevens.quarto.pub/dpavir/data/dog_breed_ranks.csv) to `ranks`, and import [`dog_breed_ranks.csv`](https://jeffreyrstevens.quarto.pub/dpavir/data/dog_breed_popularity.csv) to `popularity`.

```{r}
# >
```


2. First, set a random seed by using `set.seed(2)`. Then create a subset of `ranks` that is a random selection of 10% of the rows, sort by breed name, and assign to `ranks2`.

```{r}
# >
```


3. Use a filtering join to return the subset of `traits` that _matches_ the breeds in `ranks2` and assign this to `traits2`.

```{r}
# >
```


4. Use a filtering join to return the subset of `traits` that _excludes_ the breeds in `ranks2`.

```{r}
# >
```


5. Now we want to filter `traits` based on breeds in `popularity`. Notice that the breeds column in `popularity` is called _Breed_. This is problematic because the breed column in `traits` is called _breed_ and names are case-sensitive. Use `join_by()` to filter `traits` by breeds in `popularity`. How many rows are there?

```{r}
# >
```


6. Use `filter()` (not joins) to return the subset of `traits` that _excludes_ the breeds in `ranks2`.

```{r}
# >
```


7. Append `traits2` to the bottom of itself.

```{r}
# >
```


8. Append `traits2` to the right of itself.

```{r}
# >
```


9. Append `traits2` to the right of `ranks2`. 

```{r}
# >
```


10. Why is this not a good idea? What would be a better way to achieve this?

```{r}
# >
```

