---
title: 'Lab 7: Importing Data'
format:
  html:
    embed-resources: true
editor: source
knitr:
  opts_chunk:
    message: false
---

###### Question

::: question
Use the `library()` function to load the `tidyverse`, `janitor`, and `googlesheets4` packages.
:::


###### Question

::: question
Create a new object in R called `file_location` and assign the URL to the `pollster-ratings` CSV to it.

Confirm that this worked by typing `file_location` so that R displays the URL. 
:::


###### Question

::: question
Use `read_csv()` to load the `pollster-ratings` data into R. 
Save the resulting object as `pollster_raw`. 
:::


###### Question

::: question

Use `glimpse()` to check the number of rows and columns of `pollster_raw`, and list the names of the variables.

:::


###### Question

::: question
Use `clean_names()` to sanitize the variable names in `pollster_raw`. 
Save the resulting object as `pollster_clean`. 
:::


###### Question

::: question
Use `glimpse()` to display a listing of the names of the variables. 
What do you notice about the how the variable names are stored?
:::


###### Question

::: question
Import the raw avengers dataset and then clean up the column names.
Call the imported data `av_data`.

:::


###### Question

::: question
How many rows and columns are in the data? 
:::


###### Question

::: question
Navigate to the Google Sheet and save the URL as `gapminder_loc`. 
Confirm that this worked by typing `gapminder_loc` to display the URL. 
:::


###### Question

::: question
Earlier in this part of the lab, we stored the location of the Google Sheet as  the object `gapminder_loc`. Use this variable with `read_sheet()` to read in the first page of this Google Sheet, clean the variable names using `clean_names()`, and store the resulting data frame as the object `gm_data`.
:::


###### Question

::: question
Above, we discussed the difference between `read_sheet()` and `read_csv()`. 
Copy your code from the previous answer into a new code chunk below. Then, replace 
`read_sheet()` with `read_csv()` and `gm_data` with `gm_data2`, and run the code (note this command may take a few moments to run).

What happens when you use `read_csv()` instead of `read_sheet()` on a Google Sheet? _Hint:_ Consider the number of rows and columns. Is this what you expect?
:::


###### Question

::: question
Download and read in the `cirrhosis` dataset from your local machine using the `read_csv()` function. Then clean the column names.
:::


