Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Denis Chabot
Hi Duncan, In this case they all had length 1, but I'll be careful at other occasions. Denis Le 2011-06-05 à 09:26, Duncan Murdoch a écrit : > On 11-06-05 8:49 AM, Denis Chabot wrote: >> Thanks Duncan, I'll go back to if and else! > > Be careful, it might not give you the same answer. > > I'd

Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Duncan Murdoch
On 11-06-05 8:49 AM, Denis Chabot wrote: Thanks Duncan, I'll go back to if and else! Be careful, it might not give you the same answer. I'd use this variation on the advice from ?ifelse: new.date <- my.date + x new.date[is.na(my.date)] <- min(default.date) + x The thing to watch out for in t

Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Denis Chabot
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 wrote: >> Hi, >> >> I was "losing" my dates in a script and upon inspection, found that my >> recent switch from separate "if" and "else" t

Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Denis Chabot
Thanks Duncan, I'll go back to if and else! Denis Le 2011-06-05 à 08:39, Duncan Murdoch a écrit : > On 11-06-05 8:23 AM, Denis Chabot 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 cau

Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Gabor Grothendieck
On Sun, Jun 5, 2011 at 8:23 AM, Denis Chabot 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("2

Re: [R] ifelse strips POSIXct class from object

2011-06-05 Thread Duncan Murdoch
On 11-06-05 8:23 AM, Denis Chabot 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? See ?ifelse. The class of the result is the same as the class of the test, not the classes of t

[R] ifelse strips POSIXct class from object

2011-06-05 Thread Denis Chabot
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=