Guest User

Untitled

a guest
Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. subgps <- c(4,5,8,9,12,13,16,17,20,21,24,25,28,29,32,33)
  2. data$Variable[subgps] <- paste(" ",data$Variable[subgps])
  3. np <- ifelse(!is.na(data$Count), paste(data$Count," (",data$Percent,")",sep=""), NA)
  4. tabletext <- cbind(c("Subgroup","n",data$Variable),
  5. c("No. of Patients (%)","n",np),
  6. c("4-Yr Cum. Event Raten PCI","n",data$PCI.Group),
  7. c("4-Yr Cum. Event Raten Medical Therapy","n",data$Medical.Therapy.Group),
  8. c("P Value","n",data$P.Value))
  9.  
  10. library(forestplot)
  11. png(file.path(workdir,"Figures\Forestplot.png"),width=960, height=640)
  12. forestplot(labeltext=tabletext, graph.pos=3,
  13. mean=c(NA,NA,data$Point.Estimate),
  14. lower=c(NA,NA,data$Low), upper=c(NA,NA,data$High),
  15. title="Hazard Ratio",
  16. xlab=" <---PCI Better--- ---Medical Therapy Better--->",
  17. hrzl_lines=list("3" = gpar(lwd=1, col="#99999922"),
  18. "7" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
  19. "15" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
  20. "23" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
  21. "31" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922")),
  22. txt_gp=fpTxtGp(label=gpar(cex=1.25),
  23. ticks=gpar(cex=1.1),
  24. xlab=gpar(cex = 1.2),
  25. title=gpar(cex = 1.2)),
  26. col=fpColors(box="black", lines="black", zero = "gray50"),
  27. zero=1, cex=0.9, lineheight = "auto", boxsize=0.5, colgap=unit(6,"mm"),
  28. lwd.ci=2, ci.vertices=TRUE, ci.vertices.height = 0.4)
  29. dev.off()
  30.  
  31. install.packages("openxlsx")
  32. library(openxlsx)
  33. data <- read.xlsx("ForestPlotData.csv")
  34. # Presuming you downloaded the file correctly from the url, and its
  35. # in your working directory, and titled "ForestPlotData.csv"
Add Comment
Please, Sign In to add comment