【问题标题】:missing S3 method but higher level-function works缺少 S3 方法但更高级别的功能有效
【发布时间】:2015-07-17 22:09:27
【问题描述】:

我正在尝试确定grobWidth 应用于gtable 对象的问题(请参阅gtable:::widthDetails.gtable);将大小指定为单位总和(unit.arithmetic 对象)时会出现问题,

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')"

值得注意的是,absolute.size 有效,即使它调用 grid:::absolute.units,

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

这怎么可能?

【问题讨论】:

  • 使用npc单位之前不需要建立图框吗?
  • 不,但有趣的是,这带来了另一个问题,grid::absolute.size( unit(1,"in") + unit(2,"mm")) 产生了1null+2mm。而且我认为帝国单位很混乱。

标签: r methods r-grid gtable


【解决方案1】:

好的,浏览grid source code,发现方法是定义的,

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

但它没有被导出。所以absolute.size() 知道它,因为它在包命名空间中,但从外部调用它(例如 gtable)失败。

【讨论】:

  • 我以为你写了网格:}
  • 我的猕猴桃口音很容易出错
猜你喜欢
  • 1970-01-01
  • 2016-02-22
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-11
  • 1970-01-01
相关资源
最近更新 更多