Reputation: 3
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?
Upvotes: 0
Views: 607
Reputation: 4795
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)
Upvotes: 3
Reputation: 58875
Looking at the source, it seems not. There is an unconditional call to browseURL()
there. Maybe by making a dummy version of that function which does nothing in your global namespace, it's effect can be avoided.
browseURL <- identity
This may break other browser activity as well, so after the mcmcplot
calls, you may want to
rm(browseURL)
Alternatively, copy all the code from mcmcplot
except for the browseURL
line and use that function instead.
Upvotes: 2