# filtered parameteradpp <- adpp %>%filter(toupper(PARAMCD) =="CMAX"&toupper(PPSPEC) =="PLASMA")use_title <-paste0("Boxplot of ", as.character(unique(adpp$PARAM)), " by Visit")use_subtitle <-paste0("Analyte:\nPK Parameter: ",as.character(unique(adpp$PARAM))," (",as.character(unique(adpp$AVALU)),")")use_footnote <-"Program: \nOutput:"p <-ggplot(adpp, aes(x = AVISIT, y = AVAL, fill = ACTARM)) +geom_boxplot(outlier.size =2) +stat_boxplot(geom ="errorbar") +stat_summary(geom ="point", fun ="mean", col ="black", size =5, shape =8, position =position_dodge(0.75)) +geom_text_repel(data = . %>% dplyr::group_by(AVISIT, ACTARM) %>% dplyr::filter(AVAL %in%boxplot.stats(AVAL)$out),aes(x = AVISIT, y = AVAL, label = SUBJID, color = ACTARM),size =3, hjust =-0.2, position =position_dodge(0.75) ) +labs(title = use_title,subtitle = use_subtitle,caption = use_footnote,x ="Visit",y =paste0(as.character(unique(adpp$PARAM)), " (", as.character(unique(adpp$AVALU)), ")") ) +theme(plot.caption =element_text(hjust =0)) +theme_nest()plot <- p +geom_point(aes(fill = ACTARM), size =2, shape =21, position =position_dodge(0.75))plot
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.