Dear list,

can someone explain to me why deparse(substitute(x)) does not seem to work
when x is of a user-defined S3 class?
In my actual problem, my print method is part of a package, and the method
is registered in the NAMESPACE, if that should make a difference.

> print.testclass <- function(x,...){
  xname <- deparse(substitute(x))
  cat("Your object name is",xname,"\n")
}
 
testlist <- list()
testlist[[1]] <- 1:10
class(testlist) <- "testclass"

# This does not work as expected: 
> testlist
Your object name is structure(list(1:10), class = "testclass") 
 
# But this does :
> testlist2 <- unclass(testlist)
> print.testclass(testlist2)
Your object name is testlist2



thanks,
Remko Duursma


--
View this message in context: 
http://r.789695.n4.nabble.com/deparse-substitute-x-on-an-object-with-S3-class-tp4605592.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.

Reply via email to