R/update.gammrsea.R

update.gamMRSea<-function (object, formula., ..., evaluate = TRUE, panels=NULL)
{
  #rm('splineParams', envir = globalenv())
  splineParams<<-object$splineParams
  
  if (is.null(call <- getCall(object)))
    stop("need an object with call component")
  extras <- match.call(expand.dots = FALSE)$...
  if (!missing(formula.))
    call$formula <- update.formula(formula(object), formula.)
  if (length(extras)) {
    existing <- !is.na(match(names(extras), names(call)))
    for (a in names(extras)[existing]) call[[a]] <- extras[[a]]
    if (any(!existing)) {
      call <- c(as.list(call), extras[!existing])
      call <- as.call(call)
    }
  }
  if (evaluate) {
    #if(is.null(splineParams)){
      newmodel<-eval(call, parent.frame())  
    #}else{
    #  newmodel<-eval(call, environment())
    #}
    rm('splineParams', envir = globalenv())
    if(is.null(panels)){
      newmodel$panels<-object$panels  
    }else{
      newmodel$panels<-panels
    }
    newmodel$cvfolds<-object$cvfolds
    newmodel$varshortnames<-object$varshortnames
    newmodel$splineParams<-object$splineParams
    class(newmodel)<-class(object)
    newmodel
  }
  else{
    rm('splineParams', envir = globalenv())
    call
  }
}
lindesaysh/MRSea documentation built on April 5, 2024, 4:39 p.m.