ロケーターを使用して挿入された最後のアイテム (テキスト ボックスなど) を削除するにはどうすればよいですか? すなわち
plot(1:3)
text(locator(1),labels="oops wrong spot...remove me",cex=1,font=1)
これを可能にするものを非常に簡単に実装できます。
locator <- function(...) {
assign('.last.plot', recordPlot(), envir=.GlobalEnv)
graphics::locator(...)
}
undo <- function()
if (exists('.last.plot')) replayPlot(.last.plot)
plot(1:3)
text(locator(1),labels="oops wrong spot...remove me",cex=1,font=1)
undo()