I am currently working with reactable
in R and I am trying to find a way to retrieve the last reactable
object, similar to how ggplot2::last_plot()
is used to get the last plot object. How can I achieve this?
library(reactable)
reactable(iris)
Now I want to retrieve the last reactable
object.
Something like last_reactable()
(doesn't exist).
This should work on a session base:
reactable
) so that the quoted code of the tracer
argument executes on each call to reactable
:trace(what = reactable, tracer = quote(assign('.last_reactable_args',
as.list(match.call()[-1]),
envir = .GlobalEnv
)))
Above code grabs the arguments reactable
was called with and stores it as a hidden list in the global environment.
last_table
which calls reactable
with this list (= the latest arguments):last_reactable <- \() do.call(reactable, .last_reactable_args)
last_reactable
now replays the latest reactable
call.