从列表

时间:2018-02-07 22:16:15

标签: r survival-analysis

我试图从以下数据中提取中值

df<-structure(list(n = 26L, time = c(64, 77, 142, 148, 167, 175, 
    181, 218, 286, 294, 323, 362, 375, 414, 427, 442, 455, 460, 505, 
    543, 544, 548, 598, 604, 771, 951), n.risk = c(26, 25, 24, 23, 
    22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 
    6, 5, 4, 3, 2, 1), n.event = c(1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 
    1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0), n.censor = c(0, 
    1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
    0, 1, 0, 1), surv = c(0.961538461538462, 0.961538461538462, 0.921474358974359, 
    0.881410256410256, 0.881410256410256, 0.839438339438339, 0.839438339438339, 
    0.839438339438339, 0.839438339438339, 0.839438339438339, 0.786973443223443, 
    0.734508547008547, 0.682043650793651, 0.629578754578755, 0.577113858363858, 
    0.524648962148962, 0.524648962148962, 0.4663546330213, 0.408060303893637, 
    0.349765974765975, 0.349765974765975, 0.27981277981278, 0.209859584859585, 
    0.209859584859585, 0.104929792429792, 0.104929792429792), type = "right", 
        std.err = c(0.0392232270276368, 0.0392232270276368, 0.0578796660439579, 
        0.0729817807835649, 0.0729817807835649, 0.0877911880959172, 
        0.0877911880959172, 0.0877911880959172, 0.0877911880959172, 
        0.0877911880959172, 0.108967698764172, 0.128980092013706, 
        0.148762796526449, 0.168939711260041, 0.190043109889266, 
        0.212620066567793, 0.212620066567793, 0.24309706208875, 0.277404622263805, 
        0.317431643449181, 0.317431643449181, 0.388281918537096, 
        0.483834870173886, 0.483834870173886, 0.856794130229766, 
        0.856794130229766), upper = c(1, 1, 1, 1, 1, 0.997049673308717, 
        0.997049673308717, 0.997049673308717, 0.997049673308717, 
        0.997049673308717, 0.974346771572688, 0.945768634864856, 
        0.912933812389795, 0.876701615980298, 0.837580372384821, 
        0.795886882462859, 0.795886882462859, 0.751001648029994, 
        0.70283210436471, 0.651592180391947, 0.651592180391947, 0.598926755204663, 
        0.541713673163476, 0.541713673163476, 0.56260462703826, 0.56260462703826
        ), lower = c(0.890389006776242, 0.890389006776242, 0.822651689473135, 
        0.763934098528765, 0.763934098528765, 0.706741845048289, 
        0.706741845048289, 0.706741845048289, 0.706741845048289, 
        0.706741845048289, 0.635633245173389, 0.570438462156972, 
        0.509547937949868, 0.45211438075625, 0.397645905392106, 0.345848812876783, 
        0.345848812876783, 0.289595428067216, 0.236917480831754, 
        0.187749701094333, 0.187749701094333, 0.130725820922461, 
        0.0812994900059442, 0.0812994900059442, 0.019570157816371, 
        0.019570157816371), conf.type = "log", conf.int = 0.95, call = survfit(formula = Surv(as.numeric(as.character(all_clin$new_death))[ind_clin], 
            all_clin$death_event[ind_clin]) ~ event_rna[ind_gene, 
            ind_tum])), .Names = c("n", "time", "n.risk", "n.event", 
    "n.censor", "surv", "type", "std.err", "upper", "lower", "conf.type", 
    "conf.int", "call"), class = "survfit")

我试着像下面那样

x1 <- ifelse (is.na(as.numeric(summary(s)$table[,'median'][1])),'NA',as.numeric(summary(s)$table[,'median'][1]))
x2 <- as.numeric(summary(s)$table[,'median'][2])
if(x1 != 'NA' & x2 != 'NA'){
  lines(c(0,x1),c(0.5,0.5),col='blue')
  lines(c(x1,x1),c(0,0.5),col='black')
  lines(c(x2,x2),c(0,0.5),col='red')
}

我对这两条评论都收到以下错误

摘要中的错误$ table [,&#34; median&#34;]:维数不正确

0 个答案:

没有答案