[R] blues in c

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 25 15:50:16 CEST 2001


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.


>
> Many thanks
>
> Bernie McConnell
>
>
> "R version 1.3.1, 2001-08-31" on NT
>
> > aa <- as.POSIXct("2001-09-23")
> > bb <- as.POSIXct("2001-09-24")
> > cc <- c(aa,bb)
> > aa - bb
> Time difference of -1 days
> > aa - cc[2]
> [1] "1969-12-31 GMT Standard Time"
> Warning message:
> Incompatible methods ("-.POSIXt", "-.POSIXct") for "-"
> >
> > class(aa)
> [1] "POSIXt"  "POSIXct"
> > class(cc)
> [1] "POSIXct"
> >
> > class(cc) <- c("POSIXt", "POSIXct")
> > aa - cc[2]
> Time difference of -1 days
>
> Bernie McConnell
> NERC SEA MAMMAL RESEARCH UNIT
> Gatty Marine Lab, St Andrews University
> St Andrews, Fife,  KY16 8LB, Scotland.
>
> b.mcconnell at smru.st-andrews.ac.uk
> http://www.smru.st-and.ac.uk
> tel:  	+44 (1334) 463280
> fax:  	+44 (1334) 462632
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
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