R/terms.inner.R

#' A function taken from the survival library - it is not exported from there hence a local copy
#' 
#'
#'@title terms.inner
#'
#'@return a list of variables referred to in a formula or call object
#'@param x an R object
#'@param ... extendible arguments to the S3 method
#'@return a character vector
#'@importFrom survival Surv
#'@keywords internal

terms.inner <- function (x,...) 
{
  #if (class(x) == "formula") 
  #  c(terms.inner(x[[2]]), terms.inner(x[[3]]))
  #else 
  if (inherits(x,"call") && (x[[1]] != as.name("$") && 
                                  x[[1]] != as.name("["))) {
    if (x[[1]] == "+" || x[[1]] == "*" || x[[1]] == "-") {
      c(terms.inner(x[[2]]), terms.inner(x[[3]]))
    }
    else if (x[[1]] == as.name("Surv") || x[[1]] == as.name("rand")) 
      unlist(lapply(x[-1], terms.inner))
    else terms.inner(x[[2]])
  }
  else (deparse(x))
}

Try the rpsftm package in your browser

Any scripts or data that you put into this service are public.

rpsftm documentation built on Nov. 2, 2023, 6:07 p.m.