R/PCEpoly-class.R

Defines functions print.PCEpoly show.PCEpoly getNames.PCEpoly

Documented in print.PCEpoly

###################################################################
# plspolychaos R package
# Copyright INRA 2017
# INRA, UR1404, Research Unit MaIAGE
# F78350 Jouy-en-Josas, France.
#
# URL: http://genome.jouy.inra.fr/logiciels/plspolychaos
#
# This file is part of plspolychaos R package.
# plspolychaos is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See the GNU General Public License at:
# http://www.gnu.org/licenses/
#
###################################################################
#########################################################
# Class to store the result of functions 'polyLeg' and
# 'analyticsPolyLeg'
#########################################################
setClass("PCEpoly", slots = c(.Data = "matrix", STRUC = "PCEdesign", nvx = "numeric", 
    call = "call"))

#########################################################
# print method
# "all": option to fix the display. Vector. Valid values are:
# "FALSE" : the design only
# "TRUE": the design and the lhs
# " ..." : extend=TRUE/FALSE (option of print.PCEdesign
#          TRUE to display all the monomes)
#         and all options passed as it to print

print.PCEpoly <- function(x, all = FALSE, ...) {
    print.PCEdesign(x@STRUC, all, ...)
    cat("Number of rows:", nrow(x), "\n")
    
    if (all == TRUE) {
        cat("Created by:\n")
        print(x@call, ...)
    }
    return(invisible())
}  # end print.PCEpoly

#########################################################
## show method
show.PCEpoly <- function(object) {
    print.PCEpoly(object)
    return(invisible())
}  # end show.PCEpoly


# --------------------------------------
setMethod("show", signature(object = "PCEpoly"), definition = show.PCEpoly)

#########################################################
## getNames method
getNames.PCEpoly <- function(object) {
    
    slotnames <- slotNames(object)
    
    for (a in slotnames) {
        cat(" Slot: ", a, ".", sep = "")
        cde <- paste("class(object@", a, ")", sep = "")
        cat(" Class: \"", eval(parse(text = cde)), "\".", sep = "")
        cde <- paste("dim(object@", a, ")", sep = "")
        z <- eval(parse(text = cde))
        if (!is.null(z)) {
            cat(" Dimension: ", paste("(", paste(z, collapse = ", "), ")", sep = ""), 
                ".", sep = "")
        } else {
            cde <- paste("length(object@", a, ")", sep = "")
            z <- eval(parse(text = cde))
            if (!is.null(z)) {
                cat(" Length: ", paste("(", paste(z, collapse = ", "), ")", sep = ""), 
                  ".", sep = "")
            }
        }
        
        switch(a, .Data = {
            cat(" Legendre polynomial")
        }, STRUC = {
            cat(" The polynomial structure")
        }, nvx = {
            cat(" The number of inputs")
        }, call = {
            cat(" The command which creates the object")
        }, cat("Unknown slot ", a, "."))  # fin switch
        
        cat("\n")
        
        
    }  # fin a
    return(invisible())
}  # fin getNames


# --------------------------------------
setMethod("getNames", signature(object = "PCEpoly"), definition = getNames.PCEpoly) 

Try the plspolychaos package in your browser

Any scripts or data that you put into this service are public.

plspolychaos documentation built on May 29, 2017, 10:44 a.m.