[R] blues in c
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Sep 25 16:02:44 CEST 2001
On 25 Sep 2001, Peter Dalgaard BSA wrote:
> Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
>
> > On Tue, 25 Sep 2001, Bernie McConnell wrote:
> >
> > > G'Day,
> > >
> > > I'm a little confused why the c function has the followng effect on
> > > classes - is this a feature ? My workround [ class(cc) <- c("POSIXt",
> > > "POSIXct") ] seems to do the job.
> >
> > It's a legacy
> >
> > c.POSIXct <- function(..., recursive=FALSE)
> > structure(c(unlist(lapply(list(...), unclass))),
> > class=c("POSIXt","POSIXct"))
> >
> > does the job.
>
> Speaking of the devil... Is there any reason as.POSIXct shouldn't work
> on numeric data?
Yes, there is no way to know what it means. Numeric data is not a date!
>
> > as.POSIXct(0)
> Error in as.POSIXct.default(0) : Don't know how to convert `0' to class "POSIXct"
> > structure(0,class=c("POSIXt","POSIXct"))
> [1] "1970-01-01 01:00:00 CET"
Yes, that works, but you need to know the meaning of the numeric vector.
> (Discovered by trying
>
> c.POSIXct <- function(..., recursive=FALSE)
> as.POSIXct(c(unlist(lapply(list(...), unclass))))
>
> )
> --
> O__ ---- Peter Dalgaard Blegdamsvej 3
> c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
>
--
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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list