[R] Using substitute in a print method
Chris Stubben
stubben at lanl.gov
Fri Mar 19 21:32:33 CET 2010
I've defined a new class for some really large tables, and I'd like to use
substitute() in the print function. For example, if I define a new class
below and create a print method for it, I can't figure out how to return the
object name by just typing "d".
d<-diag(2)
class(d)<-c("diag")
print.diag<-function(x,...)
{
# do something then
print(paste( "A diagonal matrix", substitute(x)) )
}
> d
[1] "A diagonal matrix 1" "A diagonal matrix 0" "A diagonal matrix 0" "A
diagonal matrix 1"
## This prints what I'd want, but I'm not sure why its different.
print.diag(d)
[1] "A diagonal matrix d"
Thanks for any help,
Chris Stubben
--
View this message in context: http://n4.nabble.com/Using-substitute-in-a-print-method-tp1606635p1606635.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list