Created
November 9, 2022 15:54
-
-
Save MJacobs1985/c33cf1dd3269e0ea90ec8576e80da14a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try<-qol_combined%>%dplyr::select(Patientnr,variable,time,value)%>% | |
dplyr::filter(variable=="QOL_1_"|variable=="QOL_2_"|variable=="QOL_3_")%>% | |
dplyr::group_by(Patientnr,time)%>%arrange(Patientnr, time);head(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 # shows that, although missing across patients and across time, there are no missing within a form. Hence, I expect to have pf2 values! | |
PF_QOL<-try%>% | |
dplyr::summarise(pf = sum(value), pfsum = 12-pf) %>% | |
dplyr::mutate(pf2 = case_when( | |
pfsum>0 & pfsum<6 ~ pfsum*100/15, | |
pfsum == 6 ~ 7*100/15, | |
pfsum == 7 ~ 9*100/15, | |
pfsum == 8 ~ 11*100/15, | |
pfsum == 9 ~ 14*100/15, | |
TRUE ~ 0));head(PF_QOL) | |
PF_QOL$pf2<-ifelse(PF_QOL$pf2==0, NA, PF_QOL$pf2) | |
head(PF_QOL);histogram(PF_QOL$pf2) | |
g3<-ggplot(PF_QOL,aes(x=as.factor(time), y=pf2, group=as.factor(Patientnr)))+ geom_line() + geom_point() + facet_wrap(~Patientnr) + theme_bw() | |
g4<-ggplot(PF_QOL, aes(x=as.factor(time),y=pf2))+geom_boxplot()+theme_bw() | |
g2<-ggplot(PF_QOL,aes(x=as.factor(time),y=as.factor(Patientnr),fill=pf2))+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="mako", direction = -1 )+ | |
theme_grey(base_size=10)+marc_discrete | |
grid.arrange(g1,g2,g3,g4,ncol=4, top="Physical Functioning") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment