I did not know this function, thanks a lot Gabor. Denis Le 2011-06-05 à 08:48, Gabor Grothendieck a écrit :
> On Sun, Jun 5, 2011 at 8:23 AM, Denis Chabot <chabot.de...@gmail.com> wrote: >> Hi, >> >> I was "losing" my dates in a script and upon inspection, found that my >> recent switch from separate "if" and "else" to "ifelse" was the cause. But >> why? >> >> my.date = as.POSIXct("2011-06-04 08:00:00") >> default.date = seq(as.POSIXct("2011-01-01 08:00:00"), as.POSIXct("2011-09-01 >> 08:00:00"), length=15) >> x = 4 * 60 * 60 >> (my.date + x) >> (min(default.date) + x) >> (new.date = ifelse(!is.na(my.date), my.date + x, min(default.date) + x) ) >> > > Try replace: > > new.date <- replace(my.date, is.na(my.date), min(default.date)) + x > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com ______________________________________________ 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.