Dear all, I have created a new S4 class with name "MyClass". Please see
below for it's definition. Now I want to create a
method for the show() function for this class. In defining this method, what
I want is, once user would like see an object of this class
some values will be displayed. Then R will ask for **press Enter**. Once
user presses enter then, remaining values will be
displayed. In the following example, I try to explain this concept.


> setClass("MyClass", sealed = FALSE, representation(Slot1 = "vector", Slot2
= "vector"))

[1] "MyClass"

> 

> setMethod("show", "MyClass", definition = function(x) {

+         cat("These are the values. Please press enter to see the
values.\n")

+         ####### User will presss the Enter ##########

+         ####### Then only following figures will be visible #########

+         cat(x@Slot1)

+        } )

[1] "show"

Warning message:

For function "show", signature "MyClass": argument in method definition
changed from (x) to (object) 

> new("MyClass", Slot1 = 1:3, Slot2 = 4:7)

These are the values. Please press enter to see the values.

1 2 3>

 

 


Can somebody guide me how I can achieve that?


Thanks,

 


        [[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