[R] Date formats
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Dec 30 08:13:09 CET 2007
Read the warning in ?ifelse
On Dec 30, 2007 1:45 AM, Mikkel Grum <mi2kelgrum at yahoo.com> 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 at 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.
>
More information about the R-help
mailing list