From ripley at stats.ox.ac.uk  Wed Feb 25 09:04:03 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed Feb 25 09:04:32 2004
Subject: [Rd] bug in ifelse (PR#6611)
In-Reply-To: <20040224202002.BA6F8EFCA@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.44.0402250747490.3233-100000@gannet.stats>

This is already corrected in the current R-devel sources.

Note that this is an incorrect use of as.POSIXct: do read the 
description of the allowed formats:

     They can also
     convert character strings of the formats '"2001-02-03"' and
     '"2001/02/03"' optionally followed by white space and a time in
     the format '"14:52"' or '"14:52:03"'.  (Formats such as
     '"01/02/03"' are ambiguous but can be converted via a format
     specification by 'strptime'.)

and you are not getting the result I think you expected.

Finally, the result is not of class "POSIXct", which looks like an 
infelicity in ifelse.

aa <- as.POSIXct(c('1980/1/1','1980/1/2',''))
aaa <- aa
aaa[is.na(aa)] <-  as.POSIXct('1980/1/3') 

is probably what you wanted here.

On Tue, 24 Feb 2004 svetlana.eden@vanderbilt.edu wrote:

> > version
>          _
> platform i386-pc-linux-gnu
> arch     i386
> os       linux-gnu
> system   i386, linux-gnu
> status
> major    1
> minor    8.1
> year     2003
> month    11
> day      21
> language R
> > aa <- as.POSIXct(c('1/1/1980','1/2/1980',''))
> > ifelse(is.na(aa),as.POSIXct('1/3/1980'),aa)
> Error in rep.int(unclass(x), times) : Argument "times" is missing, with
> no default
> >
> 
> submitted by Frank E Harrel Jr
> 
> 
> 

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] bug in ifelse (PR#6611)
Prof Brian Ripley