该update方法trellis地块允许一个修改lattice初始呼叫后情节.但是update行为更像是替换而不是追加.这与ggplot2成语不同,其中每个新层都是已经存在的新成员.是否有可能使用这种添加剂行为lattice?
一个例子:
LL <- barchart(yield ~ variety | site, data = barley,
groups = year, stack = TRUE,
between=list(y=0.5),
scales = list(x = list(rot = 90)))
print(LL)
Run Code Online (Sandbox Code Playgroud)

现在我想添加panel.text到现有的情节中.以update下列方式使用不起作用:
update(LL, panel=function(...){
args <- list(...); panel.text(args$x, args$y+2, round(args$y, 0))
})
Run Code Online (Sandbox Code Playgroud)

我知道我可以update通过指定面板函数中的所有图层来使用:
update(LL, panel=function(...){
args <- list(...)
panel.barchart(...)
panel.text(args$x, args$y+2, round(args$y, 0))
})
Run Code Online (Sandbox Code Playgroud)
这将有效,但要求我知道lattice情节中已有的内容- 或者我对代码的重构非常重要.
问题:有没有办法添加到现有面板update.trellis?
Aar*_*ica 14
layer从latticeExtra包中看到.
library(lattice)
library(latticeExtra)
LL <- barchart(yield ~ variety | site, data = barley,
groups = year, stack = TRUE,
between=list(y=0.5),
scales = list(x = list(rot = 90)))
LL + layer(panel.text(x, y, round(y, 0), data=barley))
Run Code Online (Sandbox Code Playgroud)
