Фильтр статических ресурсов JSF Cache

Если @IShouldBuyABoat не возражает, я просто откажусь от его ответа и немного подкорректирую его.

print.survfit.select <- function (x, vars = c('records','n.max','n.start','events','median','0.95LCL','0.95UCL'), suppress = TRUE,
                                  scale = 1, digits = max(options()$digits - 4, 3), print.rmean = getOption('survfit.print.rmean'), 
                                  rmean = getOption('survfit.rmean'), ...) {

  # usage: 
  # x     survfit object
  # vars  takes c('records','n.max','n.start','events','median','0.95LCL','0.95UCL')
  # ...   see survival:::print.survfit

  if (inherits(x, 'survfitms')) {
    x$surv <- 1 - x$prev
    if (is.matrix(x$surv)) 
      dimnames(x$surv) <- list(NULL, x$states)
    if (!is.null(x$lower)) {
      x$lower <- 1 - x$lower
      x$upper <- 1 - x$upper
    }
  }
  if (!suppress) {
    if (!is.null(cl <- x$call)) {
    cat('Call: ')
    dput(cl)
    cat('\n')
    }
  }
  omit <- x$na.action
  if (length(omit)) 
    cat('  ', naprint(omit), '\n')
  savedig <- options(digits = digits)
  on.exit(options(savedig))
  if (!missing(print.rmean) && is.logical(print.rmean) && missing(rmean)) {
    if (print.rmean) 
      rmean <- 'common'
    else rmean <- 'none'
  } else {
    if (is.null(rmean)) {
      if (is.logical(print.rmean)) {
        if (print.rmean) 
          rmean <- 'common' 
        else rmean <- 'none'
      } else rmean <- 'none'
    }
    if (is.numeric(rmean)) {
      if (is.null(x$start.time)) {
        if (rmean < min(x$time)) 
          stop('Truncation point for the mean is < smallest survival')
      }
      else if (rmean < x$start.time) 
        stop('Truncation point for the mean is < smallest survival')
    } else {
      rmean <- match.arg(rmean, c('none', 'common', 'individual'))
      if (length(rmean) == 0) 
        stop('Invalid value for rmean option')
    }
  }
  temp <- survival:::survmean(x, scale = scale, rmean)

  if (is.null(x$strata)) print(temp$matrix[vars]) 
  else print(temp$matrix[ ,vars])
}

, теперь мы можем

> print.survfit.select(coxph.fit)
Call: survfit(formula = cox.ph, conf.type = "log-log")

      records n.max n.start events median 0.95LCL 0.95UCL
sex=1     138   138     138    112    270     210     306
sex=2      90    90      90     53    426     345     524
> print.survfit.select(coxph.fit, vars = c('0.95LCL','median','0.95UCL'))
Call: survfit(formula = cox.ph, conf.type = "log-log")

      0.95LCL median 0.95UCL
sex=1     210    270     306
sex=2     345    426     524

> z <- print.survfit.select(coxph.fit, vars = c('median'))
Call: survfit(formula = cox.ph, conf.type = "log-log")

sex=1 sex=2 
  270   426 
> z
sex=1 sex=2 
  270   426 

.. если кто-то другой найдет это полезным.

Еще раз спасибо!

15
задан DD. 24 February 2013 в 23:25
поделиться