File: attributes.R

package info (click to toggle)
r-cran-marginaleffects 0.32.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,784 kB
  • sloc: sh: 13; makefile: 8
file content (23 lines) | stat: -rw-r--r-- 559 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
add_attributes <- function(out, mfx = NULL, ...) {
    # Always add all attributes from S4 slots
    if (!is.null(mfx)) attr(out, "marginaleffects") <- mfx

    dots <- list(...)
    for (n in names(dots)) {
        if (is.null(attr(out, n))) {
            attr(out, n) <- dots[[n]]
        }
    }

    return(out)
}


prune_attributes <- function(out) {
    if (isTRUE(getOption("marginaleffects_lean", default = FALSE))) {
        out <- prune(out, component = "all")
    } else {
        out <- prune(out, component = "modeldata")
    }
    return(out)
}