File: Utilities.R

package info (click to toggle)
r-cran-modeltools 0.2-23-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 184 kB
  • sloc: sh: 39; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
MEapply <- function(object, FUN, clone = TRUE, ...) standardGeneric(MEapply)

setMethod("MEapply", "ModelEnv",
function(object, FUN, clone = TRUE, ...)
{
    ## If we check here, we don't have to check for the existence
    ## of hook collections every time
    if(is.null(FUN))
        return(object)
    
    z <- object
    if (clone)
        z <- clone(object, copydata = FALSE)

    for (name in ls(object@env)){
        if(is.list(FUN)){
            if(name %in% names(FUN)){
                assign(name,
                       FUN[[name]](object@get(name), ...),
                       envir = z@env)
            }
        } else {
            assign(name,
                   FUN(object@get(name), ...),
                   envir = z@env)
        }
    }

    return(z)
})