First, if I have an S4 class boo should I define S3 method for
printing print.boo(..) or should I define S4 method print(..).
I mainly need to define print function only because some user might
call it and then I would like to dispatch the call to
right function instead.
Second, it seems that by defining S4 generic function print, it is
possible to break argument hinting on the status bar.
Namely, as I understand, the Mac OS X GUI client makes a call args()
if something like
letter(
is typed to console. Since letter() function does not exists, it
should return nothing to the status bar and nothing to
console, as I as a user have not entered any call, yet. However, if S4
generic print is defined, a mysterious error
message
Error in args(letter) : no function to return from, jumping to top level
appears after typing
letter()
without return('\n') to console. It seems bizarre...
System is
Mac OS X 10.5.8 (PowerPC)
R 2.9.1 GUI 1.28 Tiger build 32-bit (5444)
R version 2.9.1 (2009-06-26)
Minimal amount of code to get the behaviour is
if(!isGeneric("print")) {setGeneric("print",useAsDefault=print)}
What is the underlying problem?
Sven Laur
Problem with S4 generic function print
2 messages · Sven Laur, Martin Morgan
Hi Sven --
Sven Laur wrote:
First, if I have an S4 class boo should I define S3 method for printing print.boo(..) or should I define S4 method print(..). I mainly need to define print function only because some user might call it and then I would like to dispatch the call to right function instead.
Usually one would define a 'show' method on S4 objects; no need for
print.boo
setMethod(show, "boo", function(object) cat("Boo!\n"))
The user gets to the right place even with print(new('boo')). Can't help
with the rest of your post.
Martin
Second, it seems that by defining S4 generic function print, it is
possible to break argument hinting on the status bar.
Namely, as I understand, the Mac OS X GUI client makes a call args() if
something like
letter(
is typed to console. Since letter() function does not exists, it should
return nothing to the status bar and nothing to
console, as I as a user have not entered any call, yet. However, if S4
generic print is defined, a mysterious error
message
Error in args(letter) : no function to return from, jumping to top level
appears after typing
letter()
without return('\n') to console. It seems bizarre...
System is
Mac OS X 10.5.8 (PowerPC)
R 2.9.1 GUI 1.28 Tiger build 32-bit (5444)
R version 2.9.1 (2009-06-26)
Minimal amount of code to get the behaviour is
if(!isGeneric("print")) {setGeneric("print",useAsDefault=print)}
What is the underlying problem?
Sven Laur
______________________________________________ R-help at 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.
Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793