Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Last active February 10, 2022 09:45
Show Gist options
  • Select an option

  • Save MJacobs1985/447188883f390e510f4a06409ad1b3da to your computer and use it in GitHub Desktop.

Select an option

Save MJacobs1985/447188883f390e510f4a06409ad1b3da to your computer and use it in GitHub Desktop.
library(readr)
library(stringr)
library(tidyverse)
library(zoo)
library(grid)
library(gridExtra)
mygrid <- read_csv("mygrid.csv")
mygrid$icds
datesplit<-str_split(mygrid$icds, "_")
df <- data.frame(matrix(unlist(datesplit), nrow=length(datesplit), byrow=TRUE))
df<-df %>%
rename(
Year = X1,
Week = X2)
df2<-cbind(df,mygrid)
df2[,4]<-NULL
df2$Date <- lubridate::make_datetime(year = df2$Year) + lubridate::weeks(df2$Week)
g1<-ggplot(df2, aes(x=Date))+
geom_point(aes(y=I21.9), col="red")+
geom_line(aes(y=I21.9), col="red")+
theme_bw()+
labs(x="Date", y="Myocard Infarct", title="Prevalence of Myocard Infarct in Germany" )
g2<-ggplot(df2, aes(x=Date))+
geom_point(aes(y=I50.9), col="blue")+
geom_line(aes(y=I50.9), col="blue")+
theme_bw()+
labs(x="Date", y="Heart Failure (unspecified)", title="Prevalence of Heart Failure (unspecified) in Germany" )
g3<-ggplot(df2, aes(x=Date))+
geom_point(aes(y=I51.9), col="seagreen")+
geom_line(aes(y=I51.9), col="seagreen")+
theme_bw()+
labs(x="Date", y="Heart Disease (unspecified)", title="Prevalence of Heart Disease (unspecified) in Germany" )
g4<-ggplot(df2, aes(x=Date))+
geom_point(aes(y=I51.4), col="purple")+
geom_line(aes(y=I51.4), col="purple")+
theme_bw()+
labs(x="Date", y="Heart Complaints (vague)", title="Prevalence of Heart Complaints (vague) in Germany" )
grid.arrange(g1,g2,g3,g4,
ncol=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment