I need some help in defining a "print" method for my new S4 class
definition. So fer I have worked like this:

setClass("MyClass", sealed=F, representation(slot1 = "list",    #create a
new class
            slot2        = "vector",
            slot3      = "vector",
            slot4   = "vector"))
setMethod("print", "MyClass", function(x) {   #set up print method for that
         cat("My Method definition.\n")
        })
newObject <- new("MyClass", slot1=list(diag(3), diag(3)), slot2="some
character", slot3="some character", slot4="some character")
print(newObject)
newObject

Here what is happening is that, if user types "newObject" then the entire
structure of this object is displayed nakedly. I want to display the same
thing which is displayed if user type "print(newObject)".

If someone guides me how to do that, it would be great.

Thanks in advance

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to