Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing S3 method but higher level-function works

I'm trying to pin down a problem with grobWidth applied to gtable objects (see gtable:::widthDetails.gtable); an issue arises when the size is specified as a 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')"

Remarkably, absolute.size works, even though it calls grid:::absolute.units,

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

How is that possible?

like image 265
baptiste Avatar asked Aug 15 '26 09:08

baptiste


1 Answers

OK, browsing the grid source code, I found out that the method is defined,

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

but it's not exported. So absolute.size() knows about it, because it's in the package namespace, but calling it from outside (e.g. gtable) fails.

like image 108
baptiste Avatar answered Aug 17 '26 22:08

baptiste



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!