?ifelse will give you
Warning

The mode of the result may depend on the value of test, and the class
attribute of the result is taken from test and may be inappropriate for the
values selected from yes and no.


i think it might answer your question,


Weiwei

On Dec 30, 2007 1:45 AM, Mikkel Grum <[EMAIL PROTECTED]> wrote:

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



-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

        [[alternative HTML version deleted]]

______________________________________________
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