File: strip_env.R

package info (click to toggle)
lme4 2.0-1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,860 kB
  • sloc: cpp: 2,543; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 515 bytes parent folder | download | duplicates (4)
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
## code for reducing prof

dropform <- function(z) {
    lapply(z, function(x) {
        environment(attr(x,"formula")) <- NULL
        x
    })
}
rpt <- function(p, hdr) {
    cat(hdr, capture.output(pryr::object_size(p)), "\n")
}

strip_profile <- function(p, quietly=FALSE) {
    
    if (!quietly) {
        rpt(p,"initial : ")
    }
    attr(p,"forward") <- dropform(attr(p,"forward"))
    attr(p,"backward") <- dropform(attr(p,"backward"))
    if (!quietly) {
        rpt(p,"final : ")
    }
    return(p)
}