parfm: R/print.select.parfm.R

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
################################################################################
#  Print method for class 'select.parfm'                                       #
################################################################################
#                                                                              #
#  This function prints the objects of class 'parfm'                           #
#                                                                              #
#  Its parameters are                                                          #
#   - x         : the object of class 'select.parfm'                           #
#   - digits    : number of significant digits                                 #
#   - na.prints : character string indicating NA values in printed output      #
#                                                                              #
#                                                                              #
#   Date:                 January, 10, 2012                                    #
#   Last modification on: December  2, 2016                                    #
################################################################################

print.select.parfm <- function(x,
                               digits=3,
                               na.print="----",
                               ...) {
    if (missing(digits))
        digits <- 3
    
    if (!is.null(x)) {
        x <- lapply(x, function(c) {
            C <- cbind(paste(' ', rownames(c)), 
                         format(c, digits = digits, justify = "right", 
                                width = max(nchar(colnames(c)))))
            rownames(C) <- rep("", nrow(C))
            C[grepl('NA', C)] <- na.print
            C[, -1] <- format(C[, -1], nsmall = max(nchar(C[, -1])),
                                justify = "right")
            colnames(C) <- format(colnames(C), justify = 'right')
            return(C)
        })

        # AIC
        colnames(x[[1]])[1] <- 'AIC:'
        print(x[[1]], quote = FALSE)
        
        cat('\n')
        
        # BIC
        colnames(x[[2]])[1] <- 'BIC:'
        print(x[[2]], quote = FALSE)
    } 
}

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.