Vim-R plugin shortcut to execute dev.off()

50 Views Asked by At

I'm often playing around with par() png() and so on, and then I often need to manually execute a random line with dev.off() in order to reset all my graphical parameters.

Looking at the doc I can't find a shortcut that would allow me to do it quickly. Did I miss something? if not, is it possible to create something similar (ie a shortcut that would send dev.off() to R)?

1

There are 1 best solutions below

2
On

From ?par:

‘par()’ (no arguments) or ‘par(no.readonly = TRUE)’ is used to get all the graphical parameters (as a named list). Their names are currently taken from the unexported variable ‘graphics:::.Pars’.

So you can do something like:

#get the default values
x<-par(no.readonly=TRUE)
#set some values
par(mfrow=c(2,1))
#plot something
plot(1:10)
plot(10:1)
#reset the pars
do.call(par,x)
#new plot
plot(1:10)