Activity 03: Data Manipulation and Visualization
-
Assigned: Friday, 18th September 2026
-
Due and Expiration: Monday, 21st September 2026 by class time.
Note: the expiration date is the last date you can submit your work for a grade.
Parts of the this activity were facilitated by Claude.
Data doesn't become useful until you shape it: filter down to what matters,
add new columns, group and summarize, and then look at it. In this
45-minute, in-class activity you will rotate through three short stations
built around two classic, built-in R datasets - penguins
(palmerpenguins) and flights (nycflights13). At each station you will
copy and paste ready-made R code into a script file using RStudio, run
it, and read the console output and plots.
You will practice the core dplyr verbs (filter(), select(),
mutate(), arrange(), group_by()/summarize()), basic missing-value
handling, joining two related tables, and building ggplot2 visualizations
(scatter plots, boxplots, bar charts, histograms) to spot trends.
By the end of this activity, you will be able to take a messy real dataset, clean it up, summarize it by group, and turn it into a plot that answers a specific question.
By completing this activity, you will be able to:
- Wrangle data with
dplyr- usefilter(),select(),mutate(),arrange(), andgroup_by()/summarize()to answer questions about a dataset - Handle missing values - detect (
is.na(),sum(),colSums()) and remove (na.omit()) missing values before summarizing - Join related tables - combine
flightsandairlineson a shared column withleft_join() - Visualize trends with
ggplot2- build scatter plots, boxplots, bar charts, and histograms, using color and faceting to compare groups - Read plots critically - describe, in writing, what a plot does and does not show
This activity guides you through one combined tutorial covering three data stations:
- Tutorial_01
- Station 1: Palmer Penguins - Wrangling Basics -
filter(),mutate(),group_by()/summarize(), missing values - Station 2: Palmer Penguins - Visualization - scatter plots, boxplots, bar charts, faceting
- Station 3: NYC Flights - Wrangling & Visualization - joining tables, missing delay values, delay trends by airline
- Station 1: Palmer Penguins - Wrangling Basics -
Each station pairs a short R script with wrap-up questions you will answer
in writing/reflection.md.
IMPORTANT: All three stations share the same package requirements. Set this up once before starting:
install.packages(c("tidyverse", "palmerpenguins", "nycflights13"))OR, if you want to first check that a library exists before automatically installing it on your machine, use the following code. This saves time in the long run since you do not have to reinstall packages you already have:
# Load required libraries, install if necessary
for (pkg in c("tidyverse", "palmerpenguins", "nycflights13")) {
if (!require(pkg, character.only = TRUE)) {
install.packages(pkg)
library(pkg, character.only = TRUE)
}
}Note: No other project setup (no uv, no virtual environment) is required for R.
- Open each station's
.Rfile insrc/to try working on the code by following the hints in the comments. If you get stuck, then remember that all the actual code is provided in the activity guide: Tutorial_01: Data Manipulation and Visualization. Please try to write the code without this using this document. - Edit each file with working code. Be sure to remove each
TODOcomment as you work. - Run each line in RStudio (
Ctrl+Enter/Cmd+Return) and read the console output and plots - Discuss what trend or pattern you see with your group (if you are working with others)
- Answer that station's wrap-up questions in
writing/reflection.mdbefore moving to the next station - Finish the General Reflection question once all three stations are complete
- Play: Time permitting? PLay with the analysis shiny app provided in
shiny_app/. Nothing to turn in for the app, just play and visit the code it provides.
There are two options that you can use to run this AMAZING CODE. Each station's script can be run independently, using a command like (or similar to) to the following terminal window command.
source("src/station_01_penguins_wrangling/explore_penguins_wrangling.R")The other way which might be easier is to simply open the file in RStudio and run it going line by line. Note: This way is recommended so you can pause and read each result.
Once you finish all three stations, if you have extra time (or want to keep exploring at home), open shiny_app/app.R in RStudio and click Run App.
This lets you:
- Choose a dataset (
penguinsorflights) - Choose the x/y variables, a grouping variable, and a plot type (scatter, boxplot, bar chart, or histogram)
- See a live summary table (mean, count) for your chosen grouping variable
- Click Show Code at any time to reveal the exact
dplyr/ggplot2code that produced the plot and table you're looking at
install.packages("shiny") # if not already installed
shiny::runApp("shiny_app")This is optional and not required for the deliverable, but it's a great way to test "what if I grouped by island instead of species?" style questions.
You will submit:
- Completed R scripts with all
TODOitems resolved for each station:src/station_01_penguins_wrangling/explore_penguins_wrangling.Rsrc/station_02_penguins_visualization/explore_penguins_visualization.Rsrc/station_03_nycflights_wrangling_viz/explore_flights.R
- Completed
writing/reflection.mdwith answers to all wrap-up and reflection questions
Note: You do NOT need to submit screenshots of your plots. Your instructor will verify functionality by running your code.
This is a check mark grade.
Please submit this assignment by pushing your work to your GitHub repository. Ensure that:
- All TODO items have been replaced with working code
- All scripts run without errors
- The reflection document is complete
- Your name has been added to all source files
Use meaningful commit messages that describe what you accomplished:
git add .
git commit -m "Complete Station 1: Penguins wrangling basics"
git pushYou can check your work by running GatorGrade:
gatorgrade --config config/gatorgrade.ymlThis will verify that:
- All required files exist
- TODO items have been removed
- Reflection questions have been answered
If you encounter difficulties: Clear your work space using the code given below.
First, try adding code at the beginning of each program to remove all left-over variables and plots from previous runs. This will ensure that you are performing a "clean run" of your programs with each run.
# Clear environment and plots
rm(list = ls()) # clear all variables
graphics.off() # clear all plots
cat("\014") # clear the console
# Load required libraries, install if necessary
for (pkg in c("tidyverse", "palmerpenguins", "nycflights13")) {
if (!require(pkg, character.only = TRUE)) {
install.packages(pkg)
library(pkg, character.only = TRUE)
}
}- Read the error messages carefully - R and RStudio provide helpful error messages
- Check the tutorial document - it contains the exact code to copy and paste. However. maybe try to write the code in R first and then check your work later?
- Consult the tidyverse documentation - https://www.tidyverse.org/
- Ask during class or office hours - bring specific questions about what you've tried
- Work with classmates - discuss the wrangling/plotting choices together, but write your own answers
When your instructor was writing this code, the following were some of the problems that he made. Nice going, huh?!
Issue: could not find function error. This one was a silly mistake.
- Solution: Make sure you ran
library(tidyverse)(andlibrary(palmerpenguins)/library(nycflights13)for that station) at the top of the script.
Issue: object 'penguins' not found or object 'flights' not found
- Solution: These datasets ship inside their packages. Make sure
library(palmerpenguins)orlibrary(nycflights13)ran without error before you referencepenguinsorflights.
Issue: Plot window doesn't show anything.
- Solution: Run the
ggplot(...)code as one full block (don't run just the first line), and check the Plots pane in RStudio. Oops!
Issue: left_join() produces NA in the name column
- Solution: Double check the join key spelling (
carrierin bothflightsandairlines) and that you didn't misspell the column name. I never been good at speling!
Looking for an extra challenge?! After completing the required stations, challenge yourself with the following nuggets of fun!
- Try a new grouping variable - in the Shiny app, group
penguinsbyislandorsexinstead ofspeciesand see if the trend changes - Investigate a specific carrier or month - filter
flightsto one airline or one month and compare its delay pattern to the overall average - Add a new summary statistic - extend a
summarize()call withsd()ormedian()and discuss how it changes your interpretation - Combine what you've learned - propose one new question about
penguinsorflightsand write thedplyr/ggplot2pipeline you would use to answer it (you don't have to run it)
Remember: The goal is not just to run the R code, but to build the habit of turning a question into a dplyr pipeline and a plot - and to read that plot critically before drawing a conclusion. But you already know all this, right!?
Now, go get 'em!

