From: <li...@us...> - 2007-09-17 09:18:10
|
Revision: 65 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=65&view=rev Author: ligges Date: 2007-09-17 02:18:14 -0700 (Mon, 17 Sep 2007) Log Message: ----------- as for BRugs: allow model.file to be a function containing a BUGS model that is written to a temporary model file Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/man/bugs.Rd Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2007-09-17 09:08:38 UTC (rev 64) +++ trunk/R2WinBUGS/R/bugs.R 2007-09-17 09:18:14 UTC (rev 65) @@ -36,6 +36,17 @@ setwd(working.directory) on.exit(setwd(savedWD)) } + if(is.function(model.file)){ + temp <- + if(is.R()){ + paste(tempfile("model"), "txt", sep=".") + } else { + gsub(".tmp$", ".txt", tempfile("model")) + } + write.model(model.file, con = temp) + model.file <- gsub("\\\\", "/", temp) + if(!is.R()) on.exit(file.remove(model.file), add = TRUE) + } if(!file.exists(model.file)) stop(paste(model.file, "does not exist.")) if(file.info(model.file)$isdir) Modified: trunk/R2WinBUGS/man/bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.Rd 2007-09-17 09:08:38 UTC (rev 64) +++ trunk/R2WinBUGS/man/bugs.Rd 2007-09-17 09:18:14 UTC (rev 65) @@ -38,7 +38,9 @@ If the extension is \file{.bug} and \code{program=="WinBUGS"}, a copy of the file with extension \file{.txt} will be created in the \code{bugs()} call and removed afterwards. Note that - similarly named \file{.txt} files will be overwritten.} + similarly named \file{.txt} files will be overwritten. + Alternatively, \code{model.file} can be an R function that contains a BUGS model that is written to a + temporary model file (see \code{\link{tempfile}}) using \code{\link{write.model}}.} \item{n.chains}{number of Markov chains (default: 3)} \item{n.iter}{number of total iterations per chain (including burn in; default: 2000)} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |