Skip to content

Instantly share code, notes, and snippets.

Last active Apr 28, 2020
What would you like to do?
A script to check whether PHE have updated their dashboard
# Check if we have new data
p_load("slackr", "naptime", "lubridate")
# Set up a repeating loop
# Check the current time
start_time <- lubridate::now()
# Download and read the file
download.file("", "export/phe_data.csv", method = "libcurl")
data <- read.csv("export/phe_data.csv")
# Check if the latest date in the data is yesterday (which means the data has been updated)
if(max(as.Date(data$ == Sys.Date()-1) {
# Send a message to a Slack channel and tag two teams
slackr_bot("*NEW DATA*: Public Health England have updated the coronavirus dashboard :chart_with_upwards_trend: <@data-and-interactives> <@graphics>",
username="Coronavirus Data Bot", channel="#channel",
# No new data? Wait two minutes and try again
print(paste("No new data as of",Sys.time(),sep=" "))
naptime(start_time + lubridate::minutes(2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment