From: <li...@us...> - 2009-02-12 18:51:55
|
Revision: 103 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=103&view=rev Author: ligges Date: 2009-02-12 18:51:52 +0000 (Thu, 12 Feb 2009) Log Message: ----------- let openbugs work in the temporary directory as well, and update the docs Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/openbugs.R trunk/R2WinBUGS/man/openbugs.Rd Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2009-02-12 12:28:59 UTC (rev 102) +++ trunk/R2WinBUGS/R/bugs.R 2009-02-12 18:51:52 UTC (rev 103) @@ -80,7 +80,7 @@ (regexpr("\\.txt$", data) > 0))) { bugs.data.file <- bugs.data(data, dir = getwd(), digits) } else { - if(inTempDir && basename(data) == data) + if(inTempDir && all(basename(data) == data)) try(file.copy(file.path(savedWD, data), data, overwrite = TRUE)) if(!file.exists(data)) stop("File", data, "does not exist.") Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2009-02-12 12:28:59 UTC (rev 102) +++ trunk/R2WinBUGS/R/openbugs.R 2009-02-12 18:51:52 UTC (rev 103) @@ -21,11 +21,14 @@ ## Move to working drirectory or temporary directory when NULL if(is.null(working.directory)) { working.directory <- tempdir() + inTempDir <- TRUE } savedWD <- getwd() setwd(working.directory) on.exit(setwd(savedWD)) + if(inTempDir && basename(model.file) == model.file) + try(file.copy(file.path(savedWD, model.file), model.file, overwrite = TRUE)) if(!file.exists(modelFile)) { stop(modelFile, " does not exist") } @@ -42,6 +45,8 @@ if(!(is.vector(data) && is.character(data) && all(file.exists(data)))) { data <- BRugs::bugsData(data, digits = digits) } + if(inTempDir && all(basename(data) == data)) + try(file.copy(file.path(savedWD, data), data, overwrite = TRUE)) BRugs::modelData(data) BRugs::modelCompile(numChains) if(missing(inits) || is.null(inits)) { @@ -52,6 +57,8 @@ inits <- BRugs::bugsInits(inits = inits, numChains = numChains, digits = digits) } + if(inTempDir && all(basename(inits) == inits)) + try(file.copy(file.path(savedWD, inits), inits, overwrite = TRUE)) BRugs::modelInits(inits) BRugs::modelGenInits() } @@ -67,8 +74,10 @@ # factories <- sub(".adaptivePhase", "", # adaptivelines[grep("adaptivePhase",adaptivelines)]) # sapply(factories, BRugs::modelSetAP, max(0, nBurnin-1)) - cat("Start to sample ...\n") - flush.console() + if(getOption("BRugsVerbose")){ + cat("Sampling has been started ...\n") + flush.console() + } BRugs::modelUpdate(nBurnin) ## BRugs::samplesSetThin(nThin) if(DIC) { Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2009-02-12 12:28:59 UTC (rev 102) +++ trunk/R2WinBUGS/man/openbugs.Rd 2009-02-12 18:51:52 UTC (rev 103) @@ -55,7 +55,8 @@ - currently unused} \item{working.directory}{sets working directory during execution of this function; \pkg{WinBUGS} in- and output will be stored in this - directory; if \code{NULL}, the current working directory is chosen.} + directory; if \code{NULL}, a temporary working directory via + \code{\link{tempdir}} is used.} } @@ -68,7 +69,7 @@ } \note{By default, BRugs (and hence \code{openbugs()}) is quite verbose. - This can be controlled for the whole BRugs package by by the option \sQuote{BRugsVerbose} (see \code{\link{options}}) + This can be controlled for the whole BRugs package by the option \sQuote{BRugsVerbose} (see \code{\link{options}}) which is set to \code{TRUE} by default. } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |