[Rd] bug in ifelse (PR#6611)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 25 09:04:03 MET 2004
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 at 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 at 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
More information about the R-devel
mailing list