Skip to content

Instantly share code, notes, and snippets.

View ryanleewatts's full-sized avatar

Ryan Watts ryanleewatts

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ryanleewatts on github.
  • I am ryanleewatts (https://keybase.io/ryanleewatts) on keybase.
  • I have a public key ASBNVxcFA4M0b1_UKKftYfc4LeS6IvpXBEmHIKtVOxmPVQo

To claim this, I am signing this object:

@ryanleewatts
ryanleewatts / Datawrapper_update.R
Last active April 24, 2020 09:17
An example of how we update a Datawrapper chart with R
# Update our worldwide cases chart
# We would replace `chartid` below with the chart’s Datawrapper id
# https://app.datawrapper.de/chart/chartid/publish
# Clean our data and get it ready for the chart
chartid <- data %>%
group_by(date) %>%
# reshape so "cases" is one column and "deaths" is another
dcast(date ~ variable, value.var = "value", fun.aggregate = sum) %>%
select(date, `Confirmed cases`, Deaths = deaths)
@ryanleewatts
ryanleewatts / Data_alert.R
Last active April 28, 2020 07:51
A script to check whether PHE have updated their dashboard
# Check if we have new data
library(pacman)
p_load("slackr", "naptime", "lubridate")
# Set up a repeating loop
repeat{
# Check the current time
start_time <- lubridate::now()
# Download and read the file
download.file("https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv", "export/phe_data.csv", method = "libcurl")
data <- read.csv("export/phe_data.csv")