Skip to content
Prev 261944 / 398502 Next

ifelse strips POSIXct class from object

On 11-06-05 8:49 AM, Denis Chabot wrote:
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 this construction is that the lengths of 
the vectors come out right.  I'm assuming that my.date + x is the same 
length as is.na(my.date)], and that min(default.date) + x is length 1, 
but I haven't tried your code to check.

Duncan Murdoch