Is the following expected behaviour for a date used in
an ifelse function?

> date <- Sys.Date()
> date
[1] "2007-12-30"
> ifelse(TRUE, date-1, date)
[1] 13876
> ifelse(FALSE, date-1, date)
[1] 13877
> ifelse(TRUE, as.character(date-1), date)
[1] "2007-12-29"
> if (TRUE) {date}
[1] "2007-12-30"

It would seem more natural to me if a date produced
the same format in an if and an ifelse function.
Moreover, as far as I can see the ifelse function
consists of hardly anything but two if functions.

Mikkel
 
> sessionInfo()
R version 2.6.1 (2007-11-26) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_Ireland.1252;LC_CTYPE=English_Ireland.1252;LC_MONETARY=English_Ireland.1252;LC_NUMERIC=C;LC_TIME=English_Ireland.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
methods   base     



      
____________________________________________________________________________________
Be a better friend, newshound, and

______________________________________________
R-help@r-project.org 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.

Reply via email to