Advertisement
GenomicsBootCamp

tidyTuesday_02Aug2022

Aug 2nd, 2022
2,308
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.85 KB | None | 1 0
  1. # script to visualize the day of the week for the sampling
  2. # TidyTuesday data set, 02-08-2022
  3.  
  4. library(tidyverse)
  5.  
  6. # read data
  7. allFrogs <- read_delim("Oregon_spotted_frog_telemetry_at_Crane_Prairie_OR.csv", delim = ",", skip = 2)
  8.  
  9. allFrogs$newdate <- strptime(as.character(allFrogs$SurveyDate), "%m/%d/%Y")
  10.  
  11. # order the positions of weekdays
  12. positions <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
  13.  
  14. # determine the day of the week and plot results
  15. allFrogs %>%
  16.   mutate(Weekday = weekdays(newdate)) %>%
  17.   mutate(dayColor = case_when(
  18.     Weekday == "Wednesday" ~ "green3",
  19.     TRUE ~ "salmon2"
  20.   )) %>%
  21.   ggplot() +
  22.   geom_bar(aes(Weekday, fill = dayColor), show.legend = F) +
  23.   scale_x_discrete(limits = positions) +
  24.   ggtitle('It is Wednesday my dudes!!!') +
  25.   theme_bw()
  26.  
  27. ggsave("tidyTuesdayFrogs.png")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement