---
title: "Lab Assignment 2"
subtitle: "Visualizing Data"
author: [Your name here]
date: today
format:
  html:
    theme: cosmo
    toc: true
    toc-location: left
    toc-depth: 2
    highlight-style: github
    code-copy: true
    embed-resources: true
    df-print: paged
    fig-align: center
    fig-width: 8
    fig-height: 5
execute:
  message: false
editor: visual
---

*Note: The header at the top of this file has a bunch of settings to make your rendered html look nice. Don't worry about it (just add your name)!*

## Instructions

Welcome to your second lab assignment! Please read the following instructions before you begin.

For your lab assignments, you may use AI to help you code. You will be required to explicitly fill out the **SPARCK** framework for each question. You may not use AI to write the non-coding parts of the framework, although you may consult it for assistance.

As you write code, think about what we've learned in class so far, and especially what we learned in the Data Visualization tutorial. You don't need to exclusively use functions we used in class, but they should serve as a reminder of the types of things you might wish to do.

You should guide me through the answer the questions. This means you shouldn't just copy and paste code from Gemini and be done with it; your **SPARCK** responses should guide me through your thought process and analysis. You might also wish to spread your code across several different chunks so you can display output along the way if you think that makes it easier to understand.

Remember that you must render your Quarto document into an html file. This html is what you should hand in on Canvas. If you encounter errors, use Gemini to help you troubleshoot!

**Make sure you put this Quarto file in your Week 4 folder, and then open the file from that folder so that R's working directory is your Week 4 folder.**

**S: Set up** (What is your end goal?)

**P: Pseudocode** (What are the steps?)

**A: AI** (What are your AI prompts?)

**R: Run** (Run it!)

**C: Check** (Did your code work?)

**K: Knowledge** (What does your code mean?)

### Visualization-specific instructions

For all graphs you make, they should look good. This means they have clear labels and pretty colors. Essentially, if you were giving a talk on this topic, your visualization should look like it belongs in your presentation.

## Question 0: The data

For this week's homework, you will be exploring (and visualizing!) a dataset from the Global Human Settlement Urban Centre Database about health metrics in urban centres. I have provided the dataset for you on our [course website](https://psyc1495f26.netlify.app/lab_tutorials). You will need to download the data and put it in your R Project folder.

The column names of the dataset are not immediately understandable - this is often the case when you download data from an external source. You often need a "data dictionary" to decode the column names. For this dataset, the data dictionary can be found [here](https://github.com/rfordatascience/tidytuesday/blob/main/data/2026/2026-09-29/health.md).

### An important first step

This dataset contains data from over 11,000 urban areas! That's a lot of concrete. There is also a very large range in size - so large, in fact, that many of our visualizations won't look very good.

As a first step, you should limit the dataset to only include larger cities. I'll let you decide what "big" means, or how many cities to include so that you still have enough data to make interesting visualizations (I'd recommend keeping AT LEAST 200 cities, but possibly more.)

## Question 1: The range of data

One of the first things we want to do when visualizing data is just get a sense of the scale of the data. We're not making comparisons yet, but simply understanding the range of values present in our data.

Pick at least 2 health metrics that are of interest to you, and for each one, make a graph that gives us a sense of what the data looks like across the entire dataset. Remember, the purpose of this graph is not to make comparisons or show relationships. It's just to show us the scale/range of the metrics present.

**S:**

**P:**

**A:**

**R:**

```{r}

```

(You may insert as many code chunks as you'd like. You can do so by going to Insert \> Executable Cell \> R in the toolbar above.)

**C:**

**K:**

**Explain what your plots show:**

## Question 2: Comparing groups

Make a graph that shows differences on a health metric between groups. Think about which variables in this dataset represent "groups" and which one you find most interesting to compare across.

**S:**

**P:**

**A:**

**R:**

```{r}

```

(You may insert as many code chunks as you'd like. You can do so by going to Insert \> Executable Cell \> R in the toolbar above.)

**C:**

**K:**

**Explain what your plot shows:**

## Question 3: Relationships

Visualize the relationship (or non-relationship) between two metrics in this dataset. This may be between two health metrics, or between one health metric and one non-health metric. (i.e. population or area)

**S:**

**P:**

**A:**

**R:**

```{r}

```

(You may insert as many code chunks as you'd like. You can do so by going to Insert \> Executable Cell \> R in the toolbar above.)

**C:**

**K:**

**Explain what your plot shows:**
