Skip to content

Instantly share code, notes, and snippets.

@jrosell
Last active October 21, 2021 09:54
Show Gist options
  • Save jrosell/7cde427d5f6f9dec0fb4ca3ee558dd81 to your computer and use it in GitHub Desktop.
Save jrosell/7cde427d5f6f9dec0fb4ca3ee558dd81 to your computer and use it in GitHub Desktop.
library(tidyverse)
if(!require(timetk)) install.packages("timetk")
# Week number in x axis with daily data in y
timetk::bike_sharing_daily %>%
filter(dteday > '2012-11-01') %>%
ggplot(aes(dteday, windspeed)) +
geom_line() +
scale_x_date(
date_breaks = "1 week",
date_labels = "%W"
) +
labs(x = "week")
# Week number in x axis with average weekly data in y
bike_sharing_weekly <- timetk::bike_sharing_daily %>%
filter(dteday > '2012-11-01') %>%
group_by(week = lubridate::week(dteday)) %>%
summarise(windspeed = mean(windspeed))
bike_sharing_weekly %>%
ggplot(aes(week, windspeed)) +
geom_line() +
scale_x_continuous(n.breaks = nrow(bike_sharing_weekly)) +
labs(y = "windspeed mean")
@jrosell
Copy link
Author

jrosell commented Oct 21, 2021

week_axis
week_windspeed_mean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment