S3 method is missing, but higher level function works

I'm trying to figure out the problem with grobWidth

being applied to objects gtable

(see gtable:::widthDetails.gtable

); the problem occurs when the size is given as the sum of units ( unit.arithmetic

object),

library(grid)
u = unit(1,"npc") + unit(2,"mm")
grid:::absolute.units(u)
#Error in UseMethod("absolute.units") : 
# no applicable method for 'absolute.units' applied to an object of class #"c('unit.arithmetic', 'unit')"

      

It is noteworthy that it absolute.size

works, although it causes grid:::absolute.units

,

grid::absolute.size(u)
#[1] 1null+2mm

      

How is this possible?

+3


source to share


1 answer


OK, looking through the source code of the grid , I found out that the method is defined,

grid:::absolute.units.unit.arithmetic(u)

      



but it is not exported. So is absolute.size()

aware of it because it is in the package namespace but calls it from outside (like gtable).

+3


source







All Articles