---
title: "Exercise 2.1"
author: "Put Your Name Here"
output:
  html_document:
    toc: true
---

<!-- You can knit this document at any time to see the draft of your answer. 
     An html file will be produced in the same folder as the Rmd file. -->

<!-- When you have completed the exercise, knit the document for the final time. -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  echo = TRUE,
  comment = NA,
  fig.width = 7,
  fig.height = 4,
  dpi = 130
)
```
In this exercise, we will required the `tidyverse`, `gt` and `janitor` packages.

```{r packages, message = FALSE, warning = FALSE}
library(tidyverse)
library(gt)
library(janitor)
```

The goal of this exercise is to produce some data summaries and get some experience using pipes (`%>%`). The Metropolitan Museum of Art in New York City maintains a database of more than 470,000 artworks. For the purposes of this exercise, we are going to focus on a small number of European paintings.

### (a) Read in the file containing European paintings and take a look at it in RStudio.

> The file is called `MetEuro.csv` and you can read the file in using the `read_csv` function. Choose `met_euro` as the name if you want to be consistent with the solutions we provide.
>
> Once you have read the file in as a data frame, you will find it in the Environment tab in RStudio and can explore it more there.

### (b) Consider what each of the variables might refer to. How many European paintings are included in this data set? 


### (c) Produce a frequency table for the Artist nationality. Which one is the most common? 

> Use `tabyl` to look at this variable. Recall that `gt()` produces nicely formatted tables.

### (d) Produce a frequency table for Medium and try adding percentages. Which Medium is the most common? 

> You can use the `adorn` options to produce actual percentages for your table.

### (e) Summarise the Object Age variable. What is the average age of the items in this collection? What is the age of the newest painting? And the oldest painting?

> You can use the `mean`, `min` and `max` functions within `summarise` to obtain these features. 


### (f) Summarise the Object Age variable again, but this time grouping by Medium. What is the medium of the oldest painting?

> Here we introduce `group_by` to our code above to look at the descriptive statistics by medium.


### (g) Extension exercises

> Propose some other summaries that might be of interest and provide the code to produce them.
>
> Download the dental decay file used in lectures and attempt to produce your own summaries.

---

&copy; 2022 Statistical Consulting Centre, The University of Melbourne.
