I have got another question on defining a method for print() function for my s4 class. Here is my class definition as well as what I have done till now:
> setClass("Me", representation(x1 = "numeric", x2 = "numeric", y1 = "character")) [1] "Me" > setMethod("print", "Me", definition=function(x) { + cat("Values of x1 & x2 are:", c(x@x1, x@x2), "\n") + }) [1] "print" > new1 = new("Me", x1=rnorm(2), x2=rt(2, 1), y1="normal") > print(new1) Values of x1 & x2 are: -2.139669 -0.2102133 -0.6293572 -26.96205 However what I wanted to have that, user should have some option to print the underlying object with as much accuracy as he wants, in terms of displaying the significant digits, for example prints number of user defined precision: > print(rnorm(2), 10) [1] -0.39146522347 -0.05624702385 > print(rnorm(2), 5) [1] 0.34575 0.87486 Can somebody help me how can I get such options for my class? Additionally I want to have 2 different additional arguments for print() function of my class, so that "x1" and "x2" will be displayed in different significant digits. Thanks and regards, [[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.