Graph Challenge 9

Author

Ryan Sharifi

Published

April 28, 2025

The {plotly} package lets you turn your ggplot figures into interactive ones. You can learn more about it here: https://plotly.com/ggplot2/

For this graph challenge, I want you to create an interactive plot with the April 2025 DU survey data using ggplot and plotly. The type of plot is up to you. So is the variable or variables you’d like to show.

When you’re done, rather than hitting the “render” button, hit the “publish” button to publish your submission to RPubs. Then, submit the link to your publication on Canvas.

library(tidyverse)
library(socsci)
library(googlesheets4)
library(plotly)

#read in data
url <- "https://docs.google.com/spreadsheets/d/1npon5F_Gr40HQj8KVeHq_un7SOep4dzc6kjP0px7nLo/edit?usp=sharing"
gs4_deauth()
dt <- range_speedread(url)

#Getting rid of N/A rows
dt <- dt |>
  filter(!is.na(Q40_1), !is.na(Q41_1))

#Making the plot
plot <- ggplot(dt, 
  aes(x = Q41_1, y = Q40_1)) +
  geom_point(alpha = 0.6) +
  geom_smooth(method = "lm", se = F, color = "blue") + 
  labs(
    title = "Relationship Between Class Participation and GPA",
    x = "Class Participation (%)",
    y = "GPA"
  ) +
  theme_minimal()

# Turn into interactive plot
interactive_plot <- ggplotly(plot)

interactive_plot