2017-04-04 8 views
1

에 대한 전설을주고 싶어, 내 숲 플롯이 잘 코드forestplot : 각 4 colums 전설없이

rm(list=ls()) 
library(forestplot) 

test_data2<-data.frame(prev1=c(0, 70, NA), 
        prev0=c(0, 20, NA), 
        prev3=c(NA,NA , 30), 
        prev4=c(NA,NA , 30), 
        low1=c(0, 30, NA), 
        low0=c(0, 10, NA), 
        low3=c(NA, NA, 10), 
        low4=c(NA, NA, 10), 
        high1=c(30, 90, NA), 
        high0=c(20, 50, NA), 
        high3=c(NA,NA , 60), 
        high4=c(NA,NA , 60)) 

test_data2 <- rbind(rep(NA, 3), test_data2) 

col_no2<-grep("prev", colnames(test_data2)) 

row_names2<-list(
list("Author", "You", "Asiimwe", "Martin"), 
list("Year", "1988", "1984", "1964") 
) 


prev<-with(test_data2, cbind(prev1, prev0, prev3, prev4)) 
low<-with(test_data2, cbind(low1, low0, low3, low4)) 
high <- with(test_data2, cbind(high1, high0, high3, high4)) 

forestplot(row_names2, prev, low, high, 
     #zero = c(0, 0.01), 
     fn.ci_norm = list(list(fpDrawNormalCI, fpDrawCircleCI,  fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI) 
         ), 

     xticks = c(0,10, 20, 30, 40, 50, 60, 70, 80, 90, 100), 
     txt_gp = fpTxtGp(label = list(gpar(fontfamily = ""), 
            gpar(fontfamily = "", 
              col = "black")), 
         ticks = gpar(fontfamily = "", cex=0.8), 
         xlab = gpar(fontfamily = "", cex = 0.8)), 
     boxsize=0.15, 
     line.margin = .1, # We need to add this to avoid crowding 
     lty.ci = c(1, 2, 3, 4), 
     xlab="Prevalence (%)", 
     new_page = TRUE) 

이하로 사용하여 작동하지만, 내가 CI 각 prev1, prev2, prev3 및 prev4에 대한 전설을 둘 때, 오류가 나타나고 작동하지 않습니다.

내가 사용한 코드는 다음과 같습니다.

rm(list=ls()) 
library(forestplot) 

test_data2<-data.frame(prev1=c(0, 70, NA), 
        prev0=c(0, 20, NA), 
        prev3=c(NA,NA , 30), 
        prev4=c(NA,NA , 30), 
        low1=c(0, 30, NA), 
        low0=c(0, 10, NA), 
        low3=c(NA, NA, 10), 
        low4=c(NA, NA, 10), 
        high1=c(30, 90, NA), 
        high0=c(20, 50, NA), 
        high3=c(NA,NA , 60), 
        high4=c(NA,NA , 60)) 

test_data2 <- rbind(rep(NA, 3), test_data2) 

col_no2<-grep("prev", colnames(test_data2)) 

row_names2<-list(
list("Author", "You", "Asiimwe", "Martin"), 
list("Year", "1988", "1984", "1964") 
) 


prev<-with(test_data2, cbind(prev1, prev0, prev3, prev4)) 
low<-with(test_data2, cbind(low1, low0, low3, low4)) 
high <- with(test_data2, cbind(high1, high0, high3, high4)) 

forestplot(row_names2, prev, low, high, 
     #zero = c(0, 0.01), 
     fn.ci_norm = list(list(fpDrawNormalCI, fpDrawCircleCI,  fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI), 
         list(fpDrawNormalCI, fpDrawCircleCI, fpDrawDiamondCI, fpDrawPointCI) 
         ), 

     xticks = c(0,10, 20, 30, 40, 50, 60, 70, 80, 90, 100), 
     txt_gp = fpTxtGp(label = list(gpar(fontfamily = ""), 
            gpar(fontfamily = "", 
              col = "black")), 
         ticks = gpar(fontfamily = "", cex=0.8), 
         xlab = gpar(fontfamily = "", cex = 0.8)), 
     boxsize=0.15, 
     line.margin = .1, # We need to add this to avoid crowding 
     lty.ci = c(1, 2, 3, 4), 
     xlab="Prevalence (%)", 
     new_page = TRUE, 
     legend=c("HIV-infected", "HIV-uninfected", "All participats", "Love-you"), 
     legend_args = fpLegend(pos = list("topright"), 
           r = unit(.1, "snpc") 
          )) 

누구든지이 문제에 대해 알고 계십니까? 감사합니다.

답변

0

이것은 빠른 디버깅을 허용하는 철저한 보고서 덕분에 버그로 판명되었습니다. 1.7.1 dev 버전에서 수정되어야하며 devtools을 사용하여 설치하십시오 :

devtools::install_github("gforge/forestplot", ref="develop")