From: <woo...@us...> - 2007-05-08 21:58:38
|
Revision: 14 http://svn.sourceforge.net/bugs-r/?rev=14&view=rev Author: woodard_ Date: 2007-05-08 14:58:37 -0700 (Tue, 08 May 2007) Log Message: ----------- Fixed the handling of numbers in scientific notation by write.model in S-PLUS. The S-PLUS scientific notation is different from the WinBUGS notation. A new function was added to change the format of all numbers in scientific notation in the model text. Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.data.R trunk/R2WinBUGS/R/write.model.R Modified: trunk/R2WinBUGS/R/bugs.data.R =================================================================== --- trunk/R2WinBUGS/R/bugs.data.R 2007-05-08 21:50:38 UTC (rev 13) +++ trunk/R2WinBUGS/R/bugs.data.R 2007-05-08 21:58:37 UTC (rev 14) @@ -55,55 +55,6 @@ # Prepared DATA for input to WinBUGS. function(DATA) { - toSingleS4 = - # - # Takes numeric vector and removes digit of exponent in scientific notation (if any) - function(x) - { - xdim <- dim(x) - x <- as.character(as.single(x)) - # First to look for positives: - pplus <- regMatchPos(x, "e\\+0") - pplusind <- apply(pplus, 1, function(y) - (!any(is.na(y)))) - if(any(pplusind)) { - # Making sure that periods are in mantissa... - init <- substring(x[pplusind], 1, pplus[ - pplusind, 1] - 1) - #...preceeding exponent - pper <- regMatchPos(init, "\\.") - pperind <- apply(pper, 1, function(y) - (all(is.na(y)))) - if(any(pperind)) - init[pperind] <- paste(init[pperind], - ".0", sep = "") - # Changing the format of the exponent... - x[pplusind] <- paste(init, "E+", substring( - x[pplusind], pplus[pplusind, 2] + 1), - sep = "") - } - # Then to look for negatives: - pminus <- regMatchPos(x, "e\\-0") - pminusind <- apply(pminus, 1, function(y) - (!any(is.na(y)))) - if(any(pminusind)) { - # Making sure that periods are in mantissa... - init <- substring(x[pminusind], 1, pminus[ - pminusind, 1] - 1) - #...preceeding exponent - pper <- regMatchPos(init, "\\.") - pperind <- apply(pper, 1, function(y) - (all(is.na(y)))) - if(any(pperind)) - init[pperind] <- paste(init[pperind], - ".0", sep = "") - # Changing the format of the exponent... - x[pminusind] <- paste(init, "E-", substring( - x[pminusind], pminus[pminusind, 2] + - 1), sep = "") - } - x - } if(!is.list(DATA)) stop("DATA must be a named list or data frame.") dlnames <- names(DATA) @@ -219,4 +170,60 @@ invisible(0) } + +toSingleS4 = +# +# Takes numeric vector and removes digit of exponent in scientific notation (if any) +# +# Written by Terry Elrod. Disclaimer: This function is used at the user's own risk. +# Please send comments to Ter...@UA.... +# Revision history: 2002-11-19. Fixed to handle missing values properly. +function(x) +{ + xdim <- dim(x) + x <- as.character(as.single(x)) + + # First to look for positives: + pplus <- regMatchPos(x, "e\\+0") + pplusind <- apply(pplus, 1, function(y) + (!any(is.na(y)))) + if(any(pplusind)) { + # Making sure that periods are in mantissa... + init <- substring(x[pplusind], 1, pplus[ + pplusind, 1] - 1) + #...preceeding exponent + pper <- regMatchPos(init, "\\.") + pperind <- apply(pper, 1, function(y) + (all(is.na(y)))) + if(any(pperind)) + init[pperind] <- paste(init[pperind], + ".0", sep = "") + # Changing the format of the exponent... + x[pplusind] <- paste(init, "E+", substring( + x[pplusind], pplus[pplusind, 2] + 1), + sep = "") + } + # Then to look for negatives: + pminus <- regMatchPos(x, "e\\-0") + pminusind <- apply(pminus, 1, function(y) + (!any(is.na(y)))) + if(any(pminusind)) { + # Making sure that periods are in mantissa... + init <- substring(x[pminusind], 1, pminus[ + pminusind, 1] - 1) + #...preceeding exponent + pper <- regMatchPos(init, "\\.") + pperind <- apply(pper, 1, function(y) + (all(is.na(y)))) + if(any(pperind)) + init[pperind] <- paste(init[pperind], + ".0", sep = "") + # Changing the format of the exponent... + x[pminusind] <- paste(init, "E-", substring( + x[pminusind], pminus[pminusind, 2] + + 1), sep = "") + } + x +} + } # ends if (!is.R()) Modified: trunk/R2WinBUGS/R/write.model.R =================================================================== --- trunk/R2WinBUGS/R/write.model.R 2007-05-08 21:50:38 UTC (rev 13) +++ trunk/R2WinBUGS/R/write.model.R 2007-05-08 21:58:37 UTC (rev 14) @@ -10,5 +10,48 @@ model.text <- paste("model", model.text) } model.text <- gsub("%_%", "", model.text) + if (!is.R()){ + ## In S-PLUS, scientific notation is different than it is in WinBUGS. + ## Change the format of any numbers in scientific notation. + model.text <- replaceScientificNotation(model.text) + + ## remove the "invisible()" line. + model.text <- gsub("invisible[ ]*\\([ ]*\\)", "", model.text) + } writeLines(model.text, con = con) } + +if (!is.R()){ + +replaceScientificNotation <- function(text){ +## Change the format of any numbers in "text" that are in S-PLUS +## scientific notation to WinBUGS scientific notation + + ## First, handle the positive exponents + ## Find the first instance + ## Note that the number may or may not have a decimal point. + sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\+0[0-9]{2}", text) + + ## For every instance, replace the number + while(sciNoteLoc > -1){ + sciNoteEnd <- sciNoteLoc + attr(sciNoteLoc, "match.length")-1 + sciNote <- substring(text, sciNoteLoc, sciNoteEnd) + text <- gsub(sciNote, toSingleS4(sciNote), text) + sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\+0[0-9]{2}", text) + } + + ## Then, handle the negative exponents + ## Find the first instance + sciNoteLoc <- regexpr("[0-9]*.{0,1}[0-9]*e\\-0[0-9]{2}", text) + + ## For every instance, replace the number + while(sciNoteLoc > -1){ + sciNoteEnd <- sciNoteLoc + attr(sciNoteLoc, "match.length")-1 + sciNote <- substring(text, sciNoteLoc, sciNoteEnd) + text <- gsub(sciNote, toSingleS4(sciNote), text) + sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\-0[0-9]{2}", text) + } + + text +} +} ## ends if (!is.R()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gg...@us...> - 2007-06-12 09:55:27
|
Revision: 24 http://svn.sourceforge.net/bugs-r/?rev=24&view=rev Author: ggorjan Date: 2007-06-12 02:55:29 -0700 (Tue, 12 Jun 2007) Log Message: ----------- no need for return() and this is slightly faster Modified Paths: -------------- trunk/R2WinBUGS/R/decode.parameter.name.R trunk/R2WinBUGS/R/formatdata.R Modified: trunk/R2WinBUGS/R/decode.parameter.name.R =================================================================== --- trunk/R2WinBUGS/R/decode.parameter.name.R 2007-06-12 09:12:59 UTC (rev 23) +++ trunk/R2WinBUGS/R/decode.parameter.name.R 2007-06-12 09:55:29 UTC (rev 24) @@ -18,5 +18,5 @@ indexes <- as.numeric(unlist(strsplit(a, ","))) dimension <- length(indexes) } - return (list (root=root, dimension=dimension, indexes=indexes)) + list(root=root, dimension=dimension, indexes=indexes) } Modified: trunk/R2WinBUGS/R/formatdata.R =================================================================== --- trunk/R2WinBUGS/R/formatdata.R 2007-06-12 09:12:59 UTC (rev 23) +++ trunk/R2WinBUGS/R/formatdata.R 2007-06-12 09:55:29 UTC (rev 24) @@ -20,5 +20,5 @@ } datalist.tofile <- paste("list(", paste(unlist(datalist.string), collapse = ", "), ")", sep = "") - return(datalist.tofile) + datalist.tofile } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gg...@us...> - 2007-08-08 08:56:33
|
Revision: 34 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=34&view=rev Author: ggorjan Date: 2007-08-08 01:56:34 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Using only history(*) in batch script since history(*, history.doc) does not create separate (history.odc) log file. Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.log.R trunk/R2WinBUGS/R/bugs.script.R Modified: trunk/R2WinBUGS/R/bugs.log.R =================================================================== --- trunk/R2WinBUGS/R/bugs.log.R 2007-08-03 14:47:08 UTC (rev 33) +++ trunk/R2WinBUGS/R/bugs.log.R 2007-08-08 08:56:34 UTC (rev 34) @@ -34,7 +34,7 @@ DICEnd <- grep("history(", logfile, fixed=TRUE) - 1 ## - 1 to remove - ## "history(+, ..." + ## "history(..." if(!length(DICEnd) || !length(DICStart) || (DICEnd < DICStart)){ DICTable <- NA Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-08-03 14:47:08 UTC (rev 33) +++ trunk/R2WinBUGS/R/bugs.script.R 2007-08-08 08:56:34 UTC (rev 34) @@ -12,7 +12,6 @@ model.file } else file.path(working.directory, model.file) data <- file.path(working.directory, "data.txt") - history <- file.path(working.directory, "history.odc") coda <- file.path(working.directory, "coda") logfile <- file.path(working.directory, "log.odc") logfileTxt <- file.path(working.directory, "log.txt") @@ -40,7 +39,7 @@ "coda (*, '", native2win(coda, WINEPATH=WINEPATH), "')\n"),redo), "stats (*)\n", if(DIC) "dic.stats()\n", - "history (*, '", native2win(history, WINEPATH=WINEPATH), "')\n", + "history (*)\n", "save ('", native2win(logfile, WINEPATH=WINEPATH), "')\n", "save ('", native2win(logfileTxt, WINEPATH=WINEPATH), "')\n", file=script, sep="", append=FALSE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <woo...@us...> - 2007-08-28 18:56:06
|
Revision: 41 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=41&view=rev Author: woodard_ Date: 2007-08-28 11:56:07 -0700 (Tue, 28 Aug 2007) Log Message: ----------- Several small changes for compatibility with S-PLUS. Removal of masking of WINE functions in S-PLUS (masking was unnecessary). Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.run.R trunk/R2WinBUGS/R/bugs.script.R trunk/R2WinBUGS/R/wineutils.R Modified: trunk/R2WinBUGS/R/bugs.run.R =================================================================== --- trunk/R2WinBUGS/R/bugs.run.R 2007-08-26 18:38:35 UTC (rev 40) +++ trunk/R2WinBUGS/R/bugs.run.R 2007-08-28 18:56:07 UTC (rev 41) @@ -9,8 +9,7 @@ ## Is bugs.directory defined in Windows (where second character is : ## i.e. C:\Program...) or Unix style path? - test <- substr(bugs.directory, start=2, stop=2) == ":" - if(useWINE && test) { + if(useWINE && (substr(bugs.directory, start=2, stop=2) == ":")) { bugs.directory <- win2native(bugs.directory, newWINE=newWINE, WINEPATH=WINEPATH) } Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-08-26 18:38:35 UTC (rev 40) +++ trunk/R2WinBUGS/R/bugs.script.R 2007-08-28 18:56:07 UTC (rev 41) @@ -27,7 +27,9 @@ logFileTxt <- native2win(logFileTxt, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) inits <- paste(working.directory, "/inits", 1:n.chains, ".txt", sep="") - inits <- sapply(inits, function(x) native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)) + inits <- sapply(inits, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH, + function(x, useWINE, newWINE, WINEPATH) + {native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)}) initlist <- paste("inits (", 1:n.chains, ", '", inits, "')\n", sep="") Modified: trunk/R2WinBUGS/R/wineutils.R =================================================================== --- trunk/R2WinBUGS/R/wineutils.R 2007-08-26 18:38:35 UTC (rev 40) +++ trunk/R2WinBUGS/R/wineutils.R 2007-08-28 18:56:07 UTC (rev 41) @@ -26,85 +26,83 @@ native2win <- function(x, useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL) { - ## Translate Unix path to Windows (wine) path - if(useWINE) { - if(newWINE) { - if(is.null(WINEPATH)) WINEPATH <- findUnixBinary(x="winepath") - x <- system(paste(WINEPATH, "-w", x), intern=TRUE) - gsub("\\\\", "/", x) ## under wine BUGS cannot use \ or \\ - } else { - winedriveRTr(x) - } - } else { - x - } -} - -## TODO: why are we masking these functions in S-PLUS - -if(is.R()) { - - win2native <- function(x, useWINE=.Platform$OS.type != "windows", - newWINE=TRUE, WINEPATH=NULL) - { - ## Translate Windows path to native (unix) path + if (is.R()){ + ## Translate Unix path to Windows (wine) path if(useWINE) { if(newWINE) { if(is.null(WINEPATH)) WINEPATH <- findUnixBinary(x="winepath") - system(paste(WINEPATH, " \"", x, "\"", sep=""), intern=TRUE) + x <- system(paste(WINEPATH, "-w", x), intern=TRUE) + gsub("\\\\", "/", x) ## under wine BUGS cannot use \ or \\ } else { - winedriveTr(x) + winedriveRTr(x) } } else { x } + } else { #S-PLUS + gsub("\\\\", "/", x) } +} - winedriveMap <- function(config="~/.wine/config") - { - ## Get drive mapping table from ~/.wine/config - if(!file.exists(config)) return(NULL); - con <- readLines(config) - con <- con[- grep("^;", con)] - drive <- con[grep("^\\[Drive ", con)] - drive <- substr(drive, 8, 8) - drive <- paste(drive, ":", sep="") - path <- con[grep("Path", con)] - len <- length(drive) - path <- path[1:len] - dir <- sapply(path, - function(x) { - foo <- unlist(strsplit(x, "\"")) - foo[length(foo)] - }) - dir <- sub("%HOME%",tools::file_path_as_absolute("~"),dir) - data.frame(drive=I(drive), path=I(dir), row.names=NULL) - } - - winedriveTr <- function(windir, DriveTable=winedriveMap()) - { - ## Translate Windows path to native (Unix) path - win.dr <- substr(windir, 1, 2) - ind <- pmatch(toupper(win.dr), DriveTable$drive) - native.dr <- DriveTable$path[ind] - sub(win.dr, native.dr, windir) - } - - winedriveRTr <- function(unixpath, DriveTable=winedriveMap()) - { - ## Translate Unix path to Windows (wine) path - blocks <- strsplit(unixpath,"/")[[1]] - cblocks <- c("/",sapply(1+seq(along=blocks[-1]), - function(n) paste(blocks[1:n],collapse="/"))) - path <- match(cblocks,DriveTable$path) - if(any(!is.na(path))) { - unixdir <- cblocks[which.min(path)] - windrive <- paste(DriveTable$drive[min(path,na.rm=TRUE)],"/",sep="") - winpath <- sub("//","/",sub(unixdir,windrive,unixpath)) ## kludge +win2native <- function(x, useWINE=.Platform$OS.type != "windows", + newWINE=TRUE, WINEPATH=NULL) +{ + ## Translate Windows path to native (unix) path + if(useWINE) { + if(newWINE) { + if(is.null(WINEPATH)) WINEPATH <- findUnixBinary(x="winepath") + system(paste(WINEPATH, " \"", x, "\"", sep=""), intern=TRUE) } else { - stop("can't find equivalent Windows path: file may be inaccessible") + winedriveTr(x) } - winpath + } else { + x } +} -} # end of if(is.R()) +winedriveMap <- function(config="~/.wine/config") +{ + ## Get drive mapping table from ~/.wine/config + if(!file.exists(config)) return(NULL); + con <- readLines(config) + con <- con[- grep("^;", con)] + drive <- con[grep("^\\[Drive ", con)] + drive <- substr(drive, 8, 8) + drive <- paste(drive, ":", sep="") + path <- con[grep("Path", con)] + len <- length(drive) + path <- path[1:len] + dir <- sapply(path, + function(x) { + foo <- unlist(strsplit(x, "\"")) + foo[length(foo)] + }) + dir <- sub("%HOME%",tools::file_path_as_absolute("~"),dir) + data.frame(drive=I(drive), path=I(dir), row.names=NULL) +} + +winedriveTr <- function(windir, DriveTable=winedriveMap()) +{ + ## Translate Windows path to native (Unix) path + win.dr <- substr(windir, 1, 2) + ind <- pmatch(toupper(win.dr), DriveTable$drive) + native.dr <- DriveTable$path[ind] + sub(win.dr, native.dr, windir) +} + +winedriveRTr <- function(unixpath, DriveTable=winedriveMap()) +{ + ## Translate Unix path to Windows (wine) path + blocks <- strsplit(unixpath,"/")[[1]] + cblocks <- c("/",sapply(1+seq(along=blocks[-1]), + function(n) paste(blocks[1:n],collapse="/"))) + path <- match(cblocks,DriveTable$path) + if(any(!is.na(path))) { + unixdir <- cblocks[which.min(path)] + windrive <- paste(DriveTable$drive[min(path,na.rm=TRUE)],"/",sep="") + winpath <- sub("//","/",sub(unixdir,windrive,unixpath)) ## kludge + } else { + stop("can't find equivalent Windows path: file may be inaccessible") + } + winpath +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gg...@us...> - 2007-09-18 13:17:38
|
Revision: 66 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=66&view=rev Author: ggorjan Date: 2007-09-18 06:17:39 -0700 (Tue, 18 Sep 2007) Log Message: ----------- two minor tweaks for S-PLUS on Linux/UNIX Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/bugs.run.R Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2007-09-17 09:18:14 UTC (rev 65) +++ trunk/R2WinBUGS/R/bugs.R 2007-09-18 13:17:39 UTC (rev 66) @@ -37,15 +37,15 @@ 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) + temp <- + ifelse(is.R(), + paste(tempfile("model"), "txt", sep="."), + ifelse(.Platform$OS.type != "unix", + gsub(".tmp$", ".txt", tempfile("model")), + paste(tempfile("model"), "txt", sep="."))) + write.model(model.file, con=temp) model.file <- gsub("\\\\", "/", temp) - if(!is.R()) on.exit(file.remove(model.file), add = TRUE) + if(!is.R()) on.exit(file.remove(model.file), add=TRUE) } if(!file.exists(model.file)) stop(paste(model.file, "does not exist.")) Modified: trunk/R2WinBUGS/R/bugs.run.R =================================================================== --- trunk/R2WinBUGS/R/bugs.run.R 2007-09-17 09:18:14 UTC (rev 65) +++ trunk/R2WinBUGS/R/bugs.run.R 2007-09-18 13:17:39 UTC (rev 66) @@ -9,7 +9,7 @@ ## Is bugs.directory defined in Windows (where second character is : ## i.e. C:\Program...) or Unix style path? - if(useWINE && (substr(bugs.directory, start=2, stop=2) == ":")) { + if(useWINE && (substr(bugs.directory, 2, 2) == ":")) { bugs.directory <- win2native(bugs.directory, newWINE=newWINE, WINEPATH=WINEPATH) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Uwe L. <li...@st...> - 2007-09-18 13:34:17
|
gg...@us... wrote: > Revision: 66 > http://bugs-r.svn.sourceforge.net/bugs-r/?rev=66&view=rev > Author: ggorjan > Date: 2007-09-18 06:17:39 -0700 (Tue, 18 Sep 2007) > > Log Message: > ----------- > two minor tweaks for S-PLUS on Linux/UNIX > > Modified Paths: > -------------- > trunk/R2WinBUGS/R/bugs.R > trunk/R2WinBUGS/R/bugs.run.R > > Modified: trunk/R2WinBUGS/R/bugs.R > =================================================================== > --- trunk/R2WinBUGS/R/bugs.R 2007-09-17 09:18:14 UTC (rev 65) > +++ trunk/R2WinBUGS/R/bugs.R 2007-09-18 13:17:39 UTC (rev 66) > @@ -37,15 +37,15 @@ > 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) > + temp <- > + ifelse(is.R(), > + paste(tempfile("model"), "txt", sep="."), > + ifelse(.Platform$OS.type != "unix", Thank you for the update! Unfortunately, this are inappropriate usages of ifelse(): We know that we are working with a length 1 logical vectors here. Using ifelse() is more insecure and inefficient in such a case! I'll change that myself to if(){} else{}. > + gsub(".tmp$", ".txt", tempfile("model")), > + paste(tempfile("model"), "txt", sep="."))) > + write.model(model.file, con=temp) > model.file <- gsub("\\\\", "/", temp) > - if(!is.R()) on.exit(file.remove(model.file), add = TRUE) > + if(!is.R()) on.exit(file.remove(model.file), add=TRUE) > } > if(!file.exists(model.file)) > stop(paste(model.file, "does not exist.")) > > Modified: trunk/R2WinBUGS/R/bugs.run.R > =================================================================== > --- trunk/R2WinBUGS/R/bugs.run.R 2007-09-17 09:18:14 UTC (rev 65) > +++ trunk/R2WinBUGS/R/bugs.run.R 2007-09-18 13:17:39 UTC (rev 66) > @@ -9,7 +9,7 @@ > > ## Is bugs.directory defined in Windows (where second character is : > ## i.e. C:\Program...) or Unix style path? > - if(useWINE && (substr(bugs.directory, start=2, stop=2) == ":")) { > + if(useWINE && (substr(bugs.directory, 2, 2) == ":")) { Is there a good reason for making this code less secure? Uwe > bugs.directory <- win2native(bugs.directory, newWINE=newWINE, WINEPATH=WINEPATH) > } > > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Gregor G. <gre...@bf...> - 2007-09-18 13:40:19
|
Uwe Ligges wrote: ... > > Thank you for the update! > > Unfortunately, this are inappropriate usages of ifelse(): We know that > we are working with a length 1 logical vectors here. Using ifelse() is > more insecure and inefficient in such a case! > > I'll change that myself to if(){} else{}. I used ifelse to avoid clutter, but if(){} else{} is also Ok for me. Thanks! >> - if(useWINE && (substr(bugs.directory, start=2, stop=2) == ":")) { >> + if(useWINE && (substr(bugs.directory, 2, 2) == ":")) { > > Is there a good reason for making this code less secure? S-PLUS, does not have arguments (I do not know why) in substr and it fails with "secure version". Gregor |
From: Uwe L. <li...@st...> - 2007-09-18 13:43:59
|
Gregor Gorjanc wrote: > Uwe Ligges wrote: > ... >> >> Thank you for the update! >> >> Unfortunately, this are inappropriate usages of ifelse(): We know that >> we are working with a length 1 logical vectors here. Using ifelse() is >> more insecure and inefficient in such a case! >> >> I'll change that myself to if(){} else{}. > > I used ifelse to avoid clutter, but if(){} else{} is also Ok for me. > Thanks! > >>> - if(useWINE && (substr(bugs.directory, start=2, stop=2) == ":")) { >>> + if(useWINE && (substr(bugs.directory, 2, 2) == ":")) { >> >> Is there a good reason for making this code less secure? > > S-PLUS, does not have arguments (I do not know why) in substr and it > fails with "secure version". I see, thanks! My Windows version of S-PLUS does not have substr() at all, hence I thought yours would not have as well. S-PLUS seems to have a lot differences between operating systems. Uwe > > Gregor |
From: Gregor G. <gre...@bf...> - 2007-09-18 13:46:53
|
Uwe Ligges wrote: ... >>> Is there a good reason for making this code less secure? >> S-PLUS, does not have arguments (I do not know why) in substr and it >> fails with "secure version". > > I see, thanks! My Windows version of S-PLUS does not have substr() at > all, hence I thought yours would not have as well. S-PLUS seems to have > a lot differences between operating systems. Huh :( Dawn, are our observations correct? Gregor |
From: Dawn W. <dwo...@in...> - 2007-09-18 14:46:47
|
That's right, S-PLUS 8.0.4 on Windows does not have a substr function. Thank you, Dawn -----Original Message----- From: Gregor Gorjanc [mailto:gre...@bf...]=20 Sent: Tuesday, September 18, 2007 11:47 AM To: Uwe Ligges Cc: bug...@li...; Dawn Woodard Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R Uwe Ligges wrote: ... >>> Is there a good reason for making this code less secure? >> S-PLUS, does not have arguments (I do not know why) in substr and it >> fails with "secure version". >=20 > I see, thanks! My Windows version of S-PLUS does not have substr() at > all, hence I thought yours would not have as well. S-PLUS seems to = have > a lot differences between operating systems. Huh :( Dawn, are our observations correct? Gregor |
From: Gregor G. <gre...@bf...> - 2007-09-19 13:38:39
|
What about system() on Linux? Dawn Woodard wrote: > That's right, S-PLUS 8.0.4 on Windows does not have a substr function. > > Thank you, > Dawn > > -----Original Message----- > From: Gregor Gorjanc [mailto:gre...@bf...] > Sent: Tuesday, September 18, 2007 11:47 AM > To: Uwe Ligges > Cc: bug...@li...; Dawn Woodard > Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R > > Uwe Ligges wrote: > ... >>>> Is there a good reason for making this code less secure? >>> S-PLUS, does not have arguments (I do not know why) in substr and it >>> fails with "secure version". >> I see, thanks! My Windows version of S-PLUS does not have substr() at >> all, hence I thought yours would not have as well. S-PLUS seems to have >> a lot differences between operating systems. > > Huh :( > > Dawn, are our observations correct? > > Gregor -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty www: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europe tel: +386 (0)1 72 17 861 ---------------------------------------------------------------------- |
From: Dawn W. <dwo...@in...> - 2007-09-19 14:40:39
|
Elsewhere the R2WinBUGS code uses "substring" instead of "substr", which works in S-PLUS for Windows; we should be able to use it in place of = substr in bugs.run, sort.name, winedriveMap and winedriveTr. The arguments = "start" and "stop" in substr are called "first" and "last" in substring. See = the help file in R for more info. Thanks, Dawn -----Original Message----- From: bug...@li... [mailto:bug...@li...] On Behalf Of Dawn = Woodard Sent: Tuesday, September 18, 2007 10:49 AM To: gre...@bf...; Uwe Ligges Cc: bug...@li... Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R That's right, S-PLUS 8.0.4 on Windows does not have a substr function. Thank you, Dawn -----Original Message----- From: Gregor Gorjanc [mailto:gre...@bf...]=20 Sent: Tuesday, September 18, 2007 11:47 AM To: Uwe Ligges Cc: bug...@li...; Dawn Woodard Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R Uwe Ligges wrote: ... >>> Is there a good reason for making this code less secure? >> S-PLUS, does not have arguments (I do not know why) in substr and it >> fails with "secure version". >=20 > I see, thanks! My Windows version of S-PLUS does not have substr() at > all, hence I thought yours would not have as well. S-PLUS seems to = have > a lot differences between operating systems. Huh :( Dawn, are our observations correct? Gregor -------------------------------------------------------------------------= This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bugs-r-devel mailing list Bug...@li... https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Dawn W. <dwo...@in...> - 2007-09-19 13:53:03
|
S-PLUS does not have a "system" function on Linux that I am aware of, = and I am looking into why that is. Thanks, Dawn -----Original Message----- From: Gregor Gorjanc [mailto:gre...@bf...]=20 Sent: Wednesday, September 19, 2007 11:39 AM To: Dawn Woodard Cc: bug...@li... Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R What about system() on Linux? Dawn Woodard wrote: > That's right, S-PLUS 8.0.4 on Windows does not have a substr function. >=20 > Thank you, > Dawn >=20 > -----Original Message----- > From: Gregor Gorjanc [mailto:gre...@bf...] > Sent: Tuesday, September 18, 2007 11:47 AM > To: Uwe Ligges > Cc: bug...@li...; Dawn Woodard > Subject: Re: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R >=20 > Uwe Ligges wrote: > ... >>>> Is there a good reason for making this code less secure? >>> S-PLUS, does not have arguments (I do not know why) in substr and it >>> fails with "secure version". >> I see, thanks! My Windows version of S-PLUS does not have substr() at >> all, hence I thought yours would not have as well. S-PLUS seems to = have >> a lot differences between operating systems. >=20 > Huh :( >=20 > Dawn, are our observations correct? >=20 > Gregor --=20 Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty www: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europe tel: +386 (0)1 72 17 861 ---------------------------------------------------------------------- |
From: Gorjanc G. <Gre...@bf...> - 2007-09-19 13:55:40
|
> S-PLUS does not have a "system" function on Linux that I am aware of, and= I > am looking into why that is. There is no way for R2WinBUGS to work without system(). Gregor |
From: Dawn W. <dwo...@in...> - 2007-09-19 14:12:04
|
I think the corresponding function on S-PLUS for Linux is called "unix". Let me know whether that works. Thank you! Dawn -----Original Message----- From: Gorjanc Gregor [mailto:Gre...@bf...]=20 Sent: Wednesday, September 19, 2007 9:53 AM To: Dawn Woodard; bug...@li... Subject: RE: [Bugs-r-devel] SF.net SVN: bugs-r: [66] trunk/R2WinBUGS/R > S-PLUS does not have a "system" function on Linux that I am aware of, = and I > am looking into why that is. There is no way for R2WinBUGS to work without system(). Gregor |
From: <li...@us...> - 2007-10-04 10:11:54
|
Revision: 75 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=75&view=rev Author: ligges Date: 2007-10-04 03:11:12 -0700 (Thu, 04 Oct 2007) Log Message: ----------- bugfix for not dropping dimensions in the matrix object sims Modified Paths: -------------- trunk/R2WinBUGS/R/as.bugs.array.R trunk/R2WinBUGS/R/bugs.sims.R Modified: trunk/R2WinBUGS/R/as.bugs.array.R =================================================================== --- trunk/R2WinBUGS/R/as.bugs.array.R 2007-09-25 11:33:02 UTC (rev 74) +++ trunk/R2WinBUGS/R/as.bugs.array.R 2007-10-04 10:11:12 UTC (rev 75) @@ -87,7 +87,7 @@ } } } - sims <- sims[sample(n.sims), ] + sims <- sims[sample(n.sims), , drop = FALSE] sims.list <- summary.mean <- summary.sd <- summary.median <- vector(n.roots, mode = "list") names(sims.list) <- names(summary.mean) <- names(summary.sd) <- names(summary.median) <- root.short Modified: trunk/R2WinBUGS/R/bugs.sims.R =================================================================== --- trunk/R2WinBUGS/R/bugs.sims.R 2007-09-25 11:33:02 UTC (rev 74) +++ trunk/R2WinBUGS/R/bugs.sims.R 2007-10-04 10:11:12 UTC (rev 75) @@ -92,7 +92,7 @@ rev(n.indexes.short[[j]])), dimension.short[j]:1) } } - sims <- sims [sample(n.sims),] # scramble (for convenience in analysis) + sims <- sims [sample(n.sims), , drop = FALSE] # scramble (for convenience in analysis) sims.list <- summary.mean <- summary.sd <- summary.median <- vector(n.roots, mode = "list") names(sims.list) <- names(summary.mean) <- names(summary.sd) <- names(summary.median) <- root.short for (j in 1:n.roots){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-06 18:56:13
|
Revision: 78 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=78&view=rev Author: ligges Date: 2008-01-06 10:56:18 -0800 (Sun, 06 Jan 2008) Log Message: ----------- two typos during last commit not found by R CMD check before... Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/bugs.script.R Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:17:57 UTC (rev 77) +++ trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:56:18 UTC (rev 78) @@ -104,7 +104,7 @@ if(codaPkg) return(file.path(getwd(), paste("coda", 1:n.chains, ".txt", sep=""))) if (summary.only) { - return(log("log.txt")) + return(bugs.log("log.txt")) } sims <- c(bugs.sims(parameters.to.save, n.chains, n.iter, n.burnin, Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:17:57 UTC (rev 77) +++ trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:56:18 UTC (rev 78) @@ -5,8 +5,6 @@ newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, save.history=TRUE, bugs.data.file, bugs.inits.files) { - - output.coda <- (!summary.only) ## Write file script.txt for Bugs if((ceiling(n.iter/n.thin) - ceiling(n.burnin/n.thin)) < 2) stop ("(n.iter-n.burnin)/n.thin must be at least 2") @@ -64,7 +62,8 @@ savelist, if(DIC) "dic.set()\n", rep(c("update (", formatC(ceiling(bin), format = "d"), ")\n", - if (output.coda) c("coda (*, '", coda, "')\n")), + #if (!summary.only) ## Hmm, if coda files are not written, we do not know if WinBUGS did not fail + c("coda (*, '", coda, "')\n")), redo), "stats (*)\n", if(DIC) "dic.stats()\n", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |