diff --git a/R/getResponse.R b/R/getResponse.R index b4292847..07f5892d 100644 --- a/R/getResponse.R +++ b/R/getResponse.R @@ -15,7 +15,7 @@ getResponse.default <- function(object,...) getResponse.lm <- function(object,...) { - responsevar <- as.character(formula(object))[2] + responsevar <- deparse(formula(object)[[2]]) ans <- model.frame(object$model)[,responsevar] return(ans) } diff --git a/R/mforecast.R b/R/mforecast.R index e35893ed..4b8fc670 100644 --- a/R/mforecast.R +++ b/R/mforecast.R @@ -13,8 +13,10 @@ mlmsplit <- function(x, index=NULL){ class(x) <- "lm" y<-attr(x$terms,"response") - cn <- colnames(x$model) + yName <- colnames(x$model[[y]])[index] x$model[[y]] <- x$model[[y]][,index] + colnames(x$model)[y] <- yName + attr(x$model, "terms") <- terms(reformulate(attr(x$terms, "term.labels"), response=yName), data=x$model) if(!is.null(tsp(x$data[,1]))){ tspx <- tsp(x$data[,1]) #Consolidate ts attributes for forecast.lm @@ -23,7 +25,6 @@ mlmsplit <- function(x, index=NULL){ row.names(x$data) <- 1:max(sapply(x$data, NROW)) } - attr(x$terms,"dataClasses")[y] <- class(x$model[[y]]) x$terms <- terms(x$model) return(x) }