Search code examples
rplotmcmc

R code mcmcplots function


Is there a way to make the R mcmcplot() function not open a browser when it's called? I need to run my R code on a cluster and if mcmcplot() tries to open a browser, it will puke.

Can the output be dumped to a file maybe?


Solution

  • That function writes everything to a file and also opens it in a browser. If you dont want to open the browser I would recommend editing the function to pass whether or not you want to open in a browser as an argument. You can retreive the function by just typing its name without any parenthesis.

    mcmcplot

    then copy that output to a editor and at the beginning change the name of the function and add teh argument:

    mcmcplotnew=function (mcmcout, parms = NULL, regex = NULL, random = NULL, 
        leaf.marker = "[\\[_]", dir = tempdir(), filename = "MCMCoutput", 
        extension = "html", title = NULL, heading = title, col = NULL, 
        lty = 1, xlim = NULL, ylim = NULL, style = c("gray", "plain"), 
        greek = FALSE,ShouldIPlotinbrowser=T)   #new argument here
    

    then there are much more parts of the function

    then at the end there is

        cat("\r", rep(" ", getOption("width")), "\r", sep = "")
        cat("\n</div>\n</div>\n", file = htmlfile, append = TRUE)
        .html.end(htmlfile)
        full.name.path <- paste("file://", htmlfile, sep = "")
        browseURL(full.name.path)
        invisible(full.name.path)
    }
    

    Where you have the browsURL line, make it something like:

    if(ShouldIPlotinbrowser) { browseURL(full.name.path) }
    

    Then initialize that function before you run it with:

    mcmcplotnew(whatever, usual, arguments,then,ShouldIPlotinbrowser=F)