diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-10-14 16:20:42 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-10-14 16:21:45 +0200 |
commit | c03fa5d4e57033869cb437c1154da31abd96fc50 (patch) | |
tree | 78c034cf3a04deb8b1dc943df70e061245d26bcb /R/mhmkin.R | |
parent | b76e401a854021eaeda6f8ba262baf37b4ecfac2 (diff) |
update method for mhmkin objects, clarify comment
Diffstat (limited to 'R/mhmkin.R')
-rw-r--r-- | R/mhmkin.R | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -203,3 +203,26 @@ BIC.mhmkin <- function(object, ...) { dimnames(res) <- dimnames(object) return(res) } + +#' @export +update.mhmkin <- function(object, ..., evaluate = TRUE) { + call <- attr(object, "call") + + update_arguments <- match.call(expand.dots = FALSE)$... + + if (length(update_arguments) > 0) { + update_arguments_in_call <- !is.na(match(names(update_arguments), names(call))) + } + + for (a in names(update_arguments)[update_arguments_in_call]) { + call[[a]] <- update_arguments[[a]] + } + + update_arguments_not_in_call <- !update_arguments_in_call + if(any(update_arguments_not_in_call)) { + call <- c(as.list(call), update_arguments[update_arguments_not_in_call]) + call <- as.call(call) + } + if(evaluate) eval(call, parent.frame()) + else call +} |