We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Will be an interesting comparison. Here's the DfT coronavirus data:
library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(ggplot2) u = "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/942559/COVID-19-transport-use-statistics.ods" f = basename(u) download.file(u, f) d_original = tibble::tibble(readODS::read_ods(f, skip = 6)) names(d_original) = gsub(pattern = "\\d", replacement = "", x = names(d_original)) d = janitor::clean_names(d_original) d = d[nchar(d[[1]]) == 10, ] d$date = lubridate::dmy(d$date_weekends_and_bank_holidays_in_grey) d = d %>% select(-(cars:heavy_goods_vehicles)) d = d %>% mutate(across(all_motor_vehicles:cycling, as.numeric)) #> Warning: Problem with `mutate()` input `..1`. #> ℹ NAs introduced by coercion #> ℹ Input `..1` is `across(all_motor_vehicles:cycling, as.numeric)`. #> Warning in fn(col, ...): NAs introduced by coercion #> Warning: Problem with `mutate()` input `..1`. #> ℹ NAs introduced by coercion #> ℹ Input `..1` is `across(all_motor_vehicles:cycling, as.numeric)`. #> Warning in fn(col, ...): NAs introduced by coercion #> Warning: Problem with `mutate()` input `..1`. #> ℹ NAs introduced by coercion #> ℹ Input `..1` is `across(all_motor_vehicles:cycling, as.numeric)`. #> Warning in fn(col, ...): NAs introduced by coercion #> Warning: Problem with `mutate()` input `..1`. #> ℹ NAs introduced by coercion #> ℹ Input `..1` is `across(all_motor_vehicles:cycling, as.numeric)`. #> Warning in fn(col, ...): NAs introduced by coercion # mutate(across(cars:cycling, as.numeric)) # summary(d) droll = d %>% mutate(across(all_motor_vehicles:cycling, zoo::rollmean, k = 30, align = "right", fill = NA)) # mutate(across(cars:cycling, zoo::rollmean, k = 30, align = "right", fill = NA)) # d # nrow(d) d_long = tidyr::pivot_longer(d, cols = all_motor_vehicles:cycling) droll_long = tidyr::pivot_longer(droll, cols = all_motor_vehicles:cycling) d_long$date = as.Date(d_long$date) droll_long$date = as.Date(droll_long$date) g = ggplot(droll_long) + geom_line(aes(date, value, colour = name), size = 1.3) + geom_line(aes(date, value, colour = name), alpha = 0.3, data = d_long) + scale_y_continuous(labels = scales::percent) + theme_bw() g #> Warning: Removed 233 row(s) containing missing values (geom_path). #> Warning: Removed 51 row(s) containing missing values (geom_path).
Created on 2020-12-17 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Will be an interesting comparison. Here's the DfT coronavirus data:
Created on 2020-12-17 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: