---
title: "Data_IO_Lab Key"
output: html_document
editor_options: 
  chunk_output_type: console
---

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.  Read in the Youth Tobacco study from
http://johnmuschelli.com/intro_to_r/data/Youth_Tobacco_Survey_YTS_Data.csv
and name it `youth`

```{r}
library(readr)
youth = read_csv("http://johnmuschelli.com/intro_to_r/data/Youth_Tobacco_Survey_YTS_Data.csv")
```

2.  Check `youth` for any problems.

```{r}
problems(youth)
stop_for_problems(youth)
```

# Part 2

2. Load the `readxl` package with the `library` command. 
If it is not installed, install it via: RStudio --> Tools --> Install Packages
```{r}
library(readxl)
```


Download in the dataset of monuments from: http://johnmuschelli.com/intro_to_r/data/Monuments.xlsx file to `Monuments.xlsx`

```{r}
download.file("http://johnmuschelli.com/intro_to_r/data/Monuments.xlsx",
              destfile = "Monuments.xlsx",
              overwrite = TRUE)
```

3. Use the `read_excel()` function in the `readxl` package to read the `Monuments.xlsx` file and call the output `mon`. 

```{r}
mon = read_excel("Monuments.xlsx")
```

# Part 3

4. Write out the `mon` object as a CSV file calling it "monuments.csv", using `readr::write_csv`:

```{r}
write_csv(mon, "monuments.csv")
```


# Part 4

5. Write out the `mon` object as a RDS file calling it "monuments.rds", using `readr::write_rds`:

```{r}
readr::write_rds(mon, "monuments.rds")
```
