Skip to content

Instantly share code, notes, and snippets.

@theosanderson
Created January 17, 2023 21:02
Show Gist options
  • Save theosanderson/41a6edb012295918825e7d71b60b8ee5 to your computer and use it in GitHub Desktop.
Save theosanderson/41a6edb012295918825e7d71b60b8ee5 to your computer and use it in GitHub Desktop.
ambulance_cat2.Rmd
```{r}
library(tidyverse)
library(gganimate)
library(tweenr)
# Read in the CSV file
df <- read_csv("~/Downloads/ambulance.csv", col_names = c("date","minutes"))
df$difftime = as.difftime(df$minutes, units = 'mins')
p<-ggplot(df,aes(x=date,y=difftime))+geom_line(color="#142bdb") +coord_cartesian(ylim=c(0,NA)) + geom_hline(yintercept=18,linetype=2,color="#666666") +theme_bw() +scale_y_time(labels = function(l) strftime(l, '%M:%S')) +labs(x="Date",y="Response time\n(hours:minutes)",
title = "Mean ambulance response time for category 2 calls",caption="Category 2 refers to serious conditions, such as stroke or chest pain,\nwhich may require rapid assessment and/or urgent transport\n London data unavailable for Oct and Nov 2022", data = "Data: AmbSYS") + annotate("text",x=lubridate::ymd("2017-12-01"), y=17,color="#666666",label="Target: 18 mins", hjust=0,vjust=1)
p
a = p + transition_reveal(date) +view_follow(fixed_y = c(0,NA),fixed_x=T) +transition_reveal(date)
animate(a, renderer = file_renderer("./amb23"),height=500*1.5,width=800*1.5,res=140*1.5,nframes = 500)
```
@liamxg
Copy link

liamxg commented Apr 30, 2024

Dear @theosanderson,

Could I know if you can send the "~/Downloads/ambulance.csv" file to me, thanks.

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