I am using the system(command, input=a character vector) command on a Windows NT machine and I now get the following warning with R 1.7: Warning message: the condition has length > 1 and only the first element will be used in: if (input != "") { I think I am getting this warning because, according to Peter Dalgaard, R 1.7 now gives a warning if if() and while() are called with a vector condition. Is there anyway to fix this issue besides options(warn=-1)? Thanks.> systemfunction (command, intern = FALSE, wait = TRUE, input = "", show.output.on.console = FALSE, minimized = FALSE, invisible = FALSE) { f <- "" if (input != "") { f <- tempfile() on.exit(unlink(f)) cat(input, file = f, sep = "\n") } if (intern) flag <- 3 else { if (wait) flag <- ifelse(show.output.on.console, 2, 1) else flag <- 0 } if (invisible) flag <- 20 + flag else if (minimized) flag <- 10 + flag .Internal(system(command, as.integer(flag), f)) } <environment: namespace:base> Benjamin Stabler Transportation Planning Analysis Unit Oregon Department of Transportation 555 13th Street NE, Suite 2 Salem, OR 97301 Ph: 503-986-4104
Benjamin.STABLER at odot.state.or.us wrote:> > I am using the system(command, input=a character vector) command on a > Windows NT machine and I now get the following warning with R 1.7: > > Warning message: > the condition has length > 1 and only the first element will be used in: if > (input != "") { > > I think I am getting this warning because, according to Peter Dalgaard, R > 1.7 now gives a warning if if() and while() are called with a vector > condition. Is there anyway to fix this issue besides options(warn=-1)? > Thanks.The fix to system would be as follows (just those two lines):> > system > function (command, intern = FALSE, wait = TRUE, input = "",function (command, intern = FALSE, wait = TRUE, input = NULL,> show.output.on.console = FALSE, > minimized = FALSE, invisible = FALSE) > { > f <- "" > if (input != "") {if(!is.null(input)){> f <- tempfile() > on.exit(unlink(f)) > cat(input, file = f, sep = "\n") > } > if (intern) > flag <- 3 > else { > if (wait) > flag <- ifelse(show.output.on.console, 2, 1) > else flag <- 0 > } > if (invisible) > flag <- 20 + flag > else if (minimized) > flag <- 10 + flag > .Internal(system(command, as.integer(flag), f)) > } > <environment: namespace:base> > > Benjamin Stabler > Transportation Planning Analysis Unit > Oregon Department of Transportation > 555 13th Street NE, Suite 2 > Salem, OR 97301 Ph: 503-986-4104Uwe Ligges
On Fri, 18 Apr 2003 11:04:48 -0700, you wrote:>I am using the system(command, input=a character vector) command on a >Windows NT machine and I now get the following warning with R 1.7: > >Warning message: >the condition has length > 1 and only the first element will be used in: if >(input != "") { >This is a bug, fixed in the current patch version. To fix your own, you could edit the file library/base/R/base, as follows: 27878c27879 < system <- function(command, intern = FALSE, wait = TRUE, input = "", ---> system <- function(command, intern = FALSE, wait = TRUE, input = NULL,27883c27884 < if (input!="") { ---> if (!is.null(input)) {The top lines are the released version, the lower lines are the patch. Duncan Murdoch