Today we will…
#| label:
not #|label:
).echo: true
)!messages
and warnings
from your final document!By default, Quarto does not embed plots in the HTML document. Instead, it creates a “PA-2-files” folder which stores all your plots.
So, when you submit your HTML file, your plots are not included! How do we fix this????
Add an embed-resources: true
line to your YAML (at the beginning of your document)!
---
title: "PA 2: Using Data Visualization to Find the Penguins"
author: "Dr. T!"
format: html
editor: source
embed-resources: true
---
Different formats of the data are tidy in different ways.
Let’s make a plot of each team’s statistics!
ggplot(data = bb_wide,
mapping = aes(x = Team)
) +
geom_point(mapping = aes(y = Points,
color = "Points"),
size = 4) +
geom_point(mapping = aes(y = Assists,
color = "Assists"),
size = 4) +
geom_point(mapping = aes(y = Rebounds,
color = "Rebounds"),
size = 4) +
scale_colour_manual(
values = c("darkred", "steelblue", "forestgreen")
) +
labs(color = "Statistic")
Look at the file extension for the type of data file.
.csv
: “comma-separated values”
Name, Age
Bob, 49
Joe, 40
.xls
, .xlsx
: Microsoft Excel spreadsheet
.csv
readxl
package.txt
: plain text
Using base R
functions:
read.csv()
is for reading in .csv
files.
read.table()
and read.delim()
are for any data with “columns” (you specify the separator).
The tidyverse has some cleaned-up versions in the readr
and readxl
packages:
read_csv()
is for comma-separated data.
read_tsv()
is for tab-separated data.
read_table()
is for white-space-separated data.
read_delim()
is any data with “columns” (you specify the separator). The above are special cases.
read_xls()
and read_xlsx()
are specifically for dealing with Excel files.
Remember to load the readr
and readxl
packages first!
Structure: boxplot, scatterplot, etc.
Aesthetics: features such as color, shape, and size that map other variables to structural features.
Both the structure and aesthetics should help viewers interpret the information.
The next slide will have one point that is not like the others.
Raise your hand when you notice it.
features that we see and perceive before we even think about it
They will jump out at us in less than 250 ms.
E.g., color, form, movement, spatial location.
There is a hierarchy of features:
Gestalt Hierarchy | Graphical Feature |
---|---|
1. Enclosure | Facets |
2. Connection | Lines |
3. Proximity | White Space |
4. Similarity | Color/Shape |
Implications for practice:
Do not use rainbow color gradients!
Be conscious of what certain colors “mean”.
For categorical data, try not to use more than 7 colors:
If you need to, you can use colorRampPalette()
from the RColorBrewer
package to produce larger palettes:
To make your graphic color deficiency friendly…
To make your graphic color deficiency friendly…
To make your graphic color deficiency friendly…
There are several packages with color scheme options:
These packages have color palettes that are aesthetically pleasing and, in many cases, color deficiency friendly.
You can also take a look at other ways to find nice color palettes.
Starting with Lab 2, your labs will have an appearance / code format portion.
Review the code formatting guidelines before you submit your lab!
Each week, you will be assigned one of your peer’s labs to review their code formatting.
Part of learning to program is learning from a variety of resources. Thus, I expect you will use resources that you find on the internet.
In this class the assumed knowledge is the course materials, including the course textbook, coursework pages, and course slides. Any functions / code used outside of these materials require direct references.