one is returned value, the other one is the result from print > t0 <- ifelse(T, print("h"), print("e")) [1] "h" > t0 [1] "h"
HTH, weiwei On 4/17/07, Luca Braglia <[EMAIL PROTECTED]> wrote: > I have found a strange "ifelse" behaviour (I think) > > This works: > > > ifelse(T,1+1,1+2) > [1] 2 > > ifelse(F,1+1,1+2) > [1] 3 > > Maybe I missed something about R internals, but why > > > ifelse(T,print("hello"),print("goodbye")) > [1] "hello" > [1] "hello" > > ifelse(F,print("hello"),print("goodbye")) > [1] "goodbye" > [1] "goodbye" > > values are returned two times? I'm not sure: if it's a bug I'll post it > immediately > > Thank You > > Luca > > > Version: > platform = i486-pc-linux-gnu > arch = i486 > os = linux-gnu > system = i486, linux-gnu > status = > major = 2 > minor = 4.1 > year = 2006 > month = 12 > day = 18 > svn rev = 40228 > language = R > version.string = R version 2.4.1 (2006-12-18) > > Locale: > LC_CTYPE=it_IT.UTF-8;LC_NUMERIC=C;LC_TIME=it_IT.UTF-8;LC_COLLATE=it_IT.UTF-8;LC_MONETARY=it_IT.UTF-8;LC_MESSAGES=it_IT.UTF-8;LC_PAPER=it_IT.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=it_IT.UTF-8;LC_IDENTIFICATION=C > > Search Path: > .GlobalEnv, package:MASS, package:utils, package:stats, package:graphics, > package:grDevices, package:methods, Autoloads, package:base > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.