library(palmerpenguins)
?penguins
Today we will…
ggplot2
practice activity (30-minutes)What do you notice about these data?
The Grammar of Graphics (GoG) is a principled way of specifying exactly how to create a particular graph from a given data set. It helps us to systematically design new graphs.
Think of a graph or a data visualization as a mapping…
…FROM variables in the data set (or statistics computed from the data)…
…TO visual attributes (or “aesthetics”) of marks (or “geometric elements”) on the page/screen.
Complete this template to build a basic graphic:
Notice, every +
adds another layer to our graphic.
Tip
Notice that I’m using named arguments to make my code easier to read.
What do you expect to see after running this code?
We map variables (columns) from the data to aesthetics on the graphic using the aes()
function.
What aesthetics can we set?
Tip
See ggplot2
cheat sheet for more!
Wee use a geom_XXX()
function to represent data points.
one variable
geom_bar()
geom_density()
geom_dotplot()
geom_histogram()
geom_boxplot()
two variable
geom_boxplot()
geom_point()
geom_line()
Tip
See ggplot2
cheat sheet for more!
Every person should have a ggplot2 cheatsheet!
On the Front
On the Back
Artwork by Allison Horst
This puzzle will require knowledge of:
None of us have all these abilities. Each of us has some of these abilities.
This collaboration will require:
🌐 Coordination & Collaboration
🔧 Engineering Mindset
📊 Management
💡 Innovation
🤝 Social Responsibility
During your collaboration, you and your partner will alternate between two roles:
Computer
Coder
During your collaboration, you and your partner will alternate between two roles:
Computer
Coder
To create a specific type of graphic, we will combine aesthetics and geometric objects. When sitting down to create a plot, it’s great to start with a game plan!
aes
thetics)geom
etries do you need?Create a plot showing the number of penguins captured on each island.
island
?geom
would you use to get this plot?Create plot displaying the most common bill lengths for the penguins in these data.
bill_length_mm
?geom
would you use to get this plot?Create a plot showing the relationship between a penguin’s bill length and body mass.
bill_length_mm
and body_mass_g
?geom
would you use to get this plot?The partner whose family name starts first alphabetically starts as the Computer! The Computer needs to:
Once you have your copy, you need to:
Only one person can type at a time
If two people type at the same time, only one document will be able to save.
This requires your group to adhere to the collaborative protocol!
Code that was run on one person’s computer will not appear on another person’s computer
When you switch roles, the new Computer will need to run all the code that was typed by the previous Computer.
When you have completed the visualization tasks, you will work as a group to answer the five questions posed at the end of the document.
Each person will input the answers to these questions in the PA2 Canvas quiz.
The person who last occupied the role of Computer will print the notebook as a PDF and submit the PDF for the group.