Hi,

I am having a problem to understand why as.data.frame method doesn't
dispatch properly on my class:

> setClass("Foo", "character")
[1] "Foo"
> as.data.frame(list(foo=new("Foo", .Data="a")))
Error in as.data.frame.default(x[[i]], optional = TRUE) : 
 can't coerce Foo into a data.frame

I was expecting that this would call as.data.frame.character.


Another puzzle. If I explicitly call as.data.frame.character() it would
fail but for a different reason:

> as.data.frame.character(list(foo=new("Foo", .Data="a")))
Error in unique.default(x) : unique() applies only to vectors


I was under an impression that an instance of "Foo" would be welcome
anywhere a "character" was, but it seems to be more subtle. What am I
missing?


Thanks,
Vadim

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to