Commit d47ce57c by Eric Coissac

Add the convertion of a procmod.frame to a formula

parent b74e226c
#' @include internals.R
NULL
#' Build a formula from a procmod.frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
formula.procmod.frame = function (x, ...)
{
nm <- sapply(names(x), as.name)
if (length(nm) > 1L) {
rhs <- nm[-1L]
lhs <- nm[1L]
}
else if (length(nm) == 1L) {
rhs <- nm[1L]
lhs <- NULL
}
else stop("cannot create a formula from an empty procmod.frame")
ff <- parse(text = paste(lhs,
paste(rhs,
collapse = "+"),
sep = "~"),
keep.source = FALSE)
ff <- eval(ff)
environment(ff) <- parent.frame()
ff
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment