Reset "par" with defaut values

Enter in R or Rstudio and do:

dput(par(no.readonly = TRUE))

Copy the list() that is shown, for example for me:

list(xlog = FALSE, ylog = FALSE, adj = 0.5, ann = TRUE, ask = FALSE,
    bg = "white", bty = "o", cex = 1, cex.axis = 1, cex.lab = 1,
    cex.main = 1.2, cex.sub = 1, col = "black", col.axis = "black",
    col.lab = "black", col.main = "black", col.sub = "black",
    crt = 0, err = 0L, family = "", fg = "black", fig = c(0,
    1, 0, 1), fin = c(9.47674418604651, 8.72093023255814), font = 1L,
    font.axis = 1L, font.lab = 1L, font.main = 2L, font.sub = 1L,
    lab = c(5L, 5L, 7L), las = 0L, lend = "round", lheight = 1,
    ljoin = "round", lmitre = 10, lty = "solid", lwd = 1, mai = c(1.02,
    0.82, 0.82, 0.42), mar = c(5.1, 4.1, 4.1, 2.1), mex = 1,
    mfcol = c(1L, 1L), mfg = c(1L, 1L, 1L, 1L), mfrow = c(1L,
    1L), mgp = c(3, 1, 0), mkh = 0.001, new = FALSE, oma = c(0,
    0, 0, 0), omd = c(0, 1, 0, 1), omi = c(0, 0, 0, 0), pch = 1L,
    pin = c(8.23674418604651, 6.88093023255814), plt = c(0.0865276073619632,
    0.955680981595092, 0.11696, 0.905973333333333), ps = 12L,
    pty = "m", smo = 1, srt = 0, tck = NA_real_, tcl = -0.5,
    usr = c(1.136, 2.864, 1.136, 2.864), xaxp = c(1.5, 2.5, 2
    ), xaxs = "r", xaxt = "s", xpd = FALSE, yaxp = c(1.5, 2.5,
    2), yaxs = "r", yaxt = "s", ylbias = 0.2)

In .Rprofile, enter these commands:

parReset_env <- new.env()
assign(x="parReset", 
list(xlog = FALSE, ylog = FALSE, adj = 0.5, ann = TRUE, ask = FALSE,
    bg = "white", bty = "o", cex = 1, cex.axis = 1, cex.lab = 1,
    cex.main = 1.2, cex.sub = 1, col = "black", col.axis = "black",
    col.lab = "black", col.main = "black", col.sub = "black",
    crt = 0, err = 0L, family = "", fg = "black", fig = c(0,
    1, 0, 1), fin = c(9.47674418604651, 8.72093023255814), font = 1L,
    font.axis = 1L, font.lab = 1L, font.main = 2L, font.sub = 1L,
    lab = c(5L, 5L, 7L), las = 0L, lend = "round", lheight = 1,
    ljoin = "round", lmitre = 10, lty = "solid", lwd = 1, mai = c(1.02,
    0.82, 0.82, 0.42), mar = c(5.1, 4.1, 4.1, 2.1), mex = 1,
    mfcol = c(1L, 1L), mfg = c(1L, 1L, 1L, 1L), mfrow = c(1L,
    1L), mgp = c(3, 1, 0), mkh = 0.001, new = FALSE, oma = c(0,
    0, 0, 0), omd = c(0, 1, 0, 1), omi = c(0, 0, 0, 0), pch = 1L,
    pin = c(8.23674418604651, 6.88093023255814), plt = c(0.0865276073619632,
    0.955680981595092, 0.11696, 0.905973333333333), ps = 12L,
    pty = "m", smo = 1, srt = 0, tck = NA_real_, tcl = -0.5,
    usr = c(1.136, 2.864, 1.136, 2.864), xaxp = c(1.5, 2.5, 2
    ), xaxs = "r", xaxt = "s", xpd = FALSE, yaxp = c(1.5, 2.5,
    2), yaxs = "r", yaxt = "s", ylbias = 0.2), envir = parReset_env)
parReset <- function() par(get(x="parReset", envir = parReset_env) )

Then you can reset default parameters with:

parReset()

It can be done without the creation of an environment, but this solution preserve the default parameters even if you erase the function parReset() by error.

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04