Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Last active November 9, 2022 16:10
Show Gist options
  • Save MJacobs1985/25848be57ef717da1be0c4c050c18235 to your computer and use it in GitHub Desktop.
Save MJacobs1985/25848be57ef717da1be0c4c050c18235 to your computer and use it in GitHub Desktop.
try<-bpi_combined%>%dplyr::select(Patientnr,time,variable,value)%>%
dplyr::filter(variable=="BPI_7A"|variable=="BPI_7B"|variable=="BPI_7C"|
variable=="BPI_7D"|variable=="BPI_7E"|variable=="BPI_7F"|
variable=="BPI_7G")%>%
dplyr::group_by(Patientnr,time)%>%arrange(Patientnr, time);try
g1<-ggplot(try, aes(x=as.factor(time),y=as.factor(variable),fill=as.factor(value)))+geom_tile(colour="white",size=0.25, na.rm=TRUE)+
labs(x="",y="")+scale_y_discrete(expand=c(0,0))+
scale_fill_viridis(discrete = TRUE, option="magma", direction = -1 )+
facet_wrap(~Patientnr)+
theme_grey(base_size=10)+marc_discrete
Interference_BPI <- try%>%dplyr::summarise(Interference=mean(value));head(Interference_BPI);histogram(Interference_BPI$Interference)
g4<-ggplot(Interference_BPI, aes(x=as.factor(time), y=Interference))+geom_boxplot()+theme_bw()
g3<-ggplot(Interference_BPI, aes(x=as.factor(time), y=Interference, group=as.factor(Patientnr))) + geom_line() + geom_point() + facet_wrap(~Patientnr) + theme_bw()
g2<-ggplot(Interference_BPI, aes(x=as.factor(time), y=as.factor(Patientnr), fill=Interference)) +geom_tile(colour="white",size=0.25, na.rm=TRUE)+
labs(x="",y="")+scale_y_discrete(expand=c(0,0))+scale_fill_viridis(discrete = FALSE, option="rocket", direction = -1 )+ theme_grey(base_size=10)+marc_discrete
grid.arrange(g1,g2,g3,g4, ncol=4, top="BPI Interference")
try<-bpi_combined%>%dplyr::select(Patientnr,time,variable,value)%>%
dplyr::filter(variable=="BPI_6_")%>%
dplyr::group_by(Patientnr,time)%>%arrange(Patientnr, time);try
g1<-ggplot(try, aes(x=as.factor(time),y=as.factor(variable),fill=as.factor(value)))+geom_tile(colour="white",size=0.25, na.rm=TRUE)+
labs(x="",y="")+scale_y_discrete(expand=c(0,0))+
scale_fill_viridis(discrete = TRUE, option="magma")+
facet_wrap(~Patientnr)+
theme_grey(base_size=10)+marc_discrete
Relief_BPI<-try%>%dplyr::summarise(Relief=mean(value));head(Relief_BPI);histogram(Relief_BPI$Relief)
g4<-ggplot(Relief_BPI, aes(x=as.factor(time), y=Relief))+geom_boxplot()+theme_bw()
g3<-ggplot(Relief_BPI,aes(x=as.factor(time), y=Relief, group=as.factor(Patientnr))) + geom_line() + geom_point() + facet_wrap(~Patientnr) + theme_bw()
g2<-ggplot(Relief_BPI,aes(x=as.factor(time), y=as.factor(Patientnr),fill=Relief)) + geom_tile(colour="white",size=0.25, na.rm=TRUE)+
labs(x="",y="")+scale_y_discrete(expand=c(0,0))+scale_fill_viridis(discrete = FALSE, option="rocket")+ theme_grey(base_size=10)+marc_discrete
grid.arrange(g1,g2,g3,g4, ncol=4, top="BPI Relief")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment