[R] system() and R 1.7

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Apr 19 13:24:45 CEST 2003


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-4104


Uwe Ligges



More information about the R-help mailing list