2017-05-15 7 views
1

ggforestを使用して作成したフォレストプロットで軸を変更しようとすると、プロットが完全に変化します。例についてはggforest(森林プロット)の "survminer"のR軸を変更

#Example data set 
mydata <- data.frame(A = c(8, 6, 42, 97, 55, 1, 5, 7, 55, 4), 
        B = c(93, 9, 65, 2, 51, 89, 1, 1, 5, 62), 
        C = c(68.41, 68.86, 47.26, 31.06, 42.97, 69.16, 47.39, 56.57, 19.63, 45.58), 
        D = c(0, 0, 0, 1, 1, 0, 0, 0, 0, 0), 
        time = c(1.6, 34.6, 1.5, 35.8, 7.7, 38.6, 40.2, 4.7, 37.6, 8.6), 
        event= c(1, 0, 0, 0, 1, 0, 0, 1, 0, 1)) 


OS <- mydata$time 
Event<-mydata$event 
A<-mydata$A 
B<-mydata$B 
C<-mydata$C 
D<-mydata$D 


# load packages 
library("survival") 
library("survminer") 

# dependent and independent variables 
y <- Surv(OS, Event) 
x <- cbind(A, B, C, D) 

#cox regression 
cox<-coxph(y~x, data=mydata, method= "breslow") 
summary(cox) 


#Forest PLot using surv miner 

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model") 

Which produces this plot

そして、私はそうのように、軸を変更しようとすると...

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model", xlim=c(-10,10000)) 

..it looks like this 誰もがこの解決策を知っていますか?ここで

答えて

0

ylimオプションでcoord_flipに基づくソリューションです:

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model") + 
    coord_flip(ylim=c(10^(-4),10^6)) 

enter image description here

+0

ありがとうございました!それは素晴らしい仕事でした! – Alex

関連する問題