[Rd] Should as() find an ANY method even for an 'unregistered' S3 class?

Michael Chirico m|ch@e|ch|r|co4 @end|ng |rom gm@||@com
Thu Mar 19 15:55:18 CET 2026


OK, here is a self-contained version

setClass("integer64")
setAs("ANY", "integer64", function(from) {
  structure(from, class = "integer64")
})
x <- 1e10
class(x) <- c("foo", "integer64")
as(x, "integer64")
# Error in as(x, "integer64") :
#   internal problem in as(): “foo” is(object, "integer64") is TRUE, but
the metadata asserts that the 'is' relation is FALSE

Mike C

On Thu, Mar 19, 2026 at 2:11 AM Martin Maechler <maechler using stat.math.ethz.ch>
wrote:

> >>>>> Michael Chirico
> >>>>>     on Wed, 18 Mar 2026 10:40:11 -0700 writes:
>
>     > We have
>     >      setAs("ANY", "integer64", function(from) as.integer64(from))
>
> Sorry, but  who is "we"?
> R does not know about "integer64" nor an as.integer64()
>
> I'd expect knowledgable posters to R-devel  to use reproducible
> examples, please !?
>
> Martin
>
>     > I expected that would work to default as(x, "integer64")
>     > to use the S3 coercion, but not so for a different S3
>     > class:
>
>     > x = 1e10 class(x) = c("foo", "integer64") as(x,
>     > "integer64") # Error in as(x, "integer64") : # internal
>     > problem in as(): “foo” is(object, "integer64") is TRUE,
>     > but the metadata asserts that the 'is' relation is FALSE
>
> ....
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list