medmond919 icon

tidyTuesday_02Aug2022

medmond919 | PRO | 03/15/23 07:46:38 PM UTC | 0 ⭐ | 306 👁️ | Never ⏰ | []
R |

850 B

|

None

|

0 👍

/

0 👎

# script to visualize the day of the week for the sampling
# TidyTuesday data set, 02-08-2022
 
library(tidyverse)
 
# read data
allFrogs <- read_delim("Oregon_spotted_frog_telemetry_at_Crane_Prairie_OR.csv", delim = ",", skip = 2)
 
allFrogs$newdate <- strptime(as.character(allFrogs$SurveyDate), "%m/%d/%Y")
 
# order the positions of weekdays
positions <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
 
# determine the day of the week and plot results
allFrogs %>%
  mutate(Weekday = weekdays(newdate)) %>%
  mutate(dayColor = case_when(
    Weekday == "Wednesday" ~ "green3",
    TRUE ~ "salmon2"
  )) %>%
  ggplot() + 
  geom_bar(aes(Weekday, fill = dayColor), show.legend = F) +
  scale_x_discrete(limits = positions) +
  ggtitle('It is Wednesday my dudes!!!') +
  theme_bw()
 
ggsave("tidyTuesdayFrogs.png")
  

Comments