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. ______________________________________________ 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.