library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(googlesheets4)
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(socsci)
## Loading required package: rlang
## 
## Attaching package: 'rlang'
## 
## The following objects are masked from 'package:purrr':
## 
##     %@%, flatten, flatten_chr, flatten_dbl, flatten_int, flatten_lgl,
##     flatten_raw, invoke, splice
## 
## Loading required package: scales
## 
## Attaching package: 'scales'
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
## 
## Loading required package: broom
## Loading required package: glue
url <- "https://docs.google.com/spreadsheets/d/1npon5F_Gr40HQj8KVeHq_un7SOep4dzc6kjP0px7nLo/edit?usp=sharing"
gs4_deauth()
dt <- range_speedread(url)
## ✔ Reading from "April_2025".
## ℹ Export URL:
##   <https://docs.google.com/spreadsheets/d/1npon5F_Gr40HQj8KVeHq_un7SOep4dzc6kjP0px7nLo/export?format=csv>
## Rows: 273 Columns: 274── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (9): StartDate, EndDate, RecordedDate, ResponseId, Q24_6_TEXT, Q32_13_...
## dbl (265): Status, Progress, Duration (in seconds), Finished, Q1, Q2, Q3, Q4...
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Including Plots

dt_long <- dt |> 
  pivot_longer(
    cols = starts_with("Q6_"), 
    names_to = "platform_id", 
    values_to = "rating") |> 
  mutate(platform = frcode(
    platform_id == "Q6_1" ~ "TikTok", 
    platform_id == "Q6_2" ~ "Twitter/X", 
    platform_id == "Q6_3" ~ "YouTube", 
    platform_id == "Q6_4" ~ "Radio/Television", 
    platform_id == "Q6_5" ~ "News App/Website" 
    )
  ) |>
  filter(!is.na(rating)) |>
  select(-platform_id)

dt_long |> 
  group_by(platform) |> 
  summarise(
    avg_rating = mean(rating)
    ) |> 
  mutate(
    avg_rating = round(avg_rating)
  ) |>
  plot_ly(
    x = ~platform,
    y = ~avg_rating, 
    type = 'bar'
    ) |>
  layout(
    title = "Denisonians Rate How Much News They Get From Various Platforms \n(0 = none, 100 = A lot)",
    xaxis = list(title = "Platform"),
    yaxis = list(title = "Average Rating")
  )

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.