Skip to content

blues in c

4 messages · Bernie McConnell, Brian Ripley, Peter Dalgaard

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

Many thanks

Bernie McConnell


"R version 1.3.1, 2001-08-31" on NT
Time difference of -1 days
[1] "1969-12-31 GMT Standard Time"
Warning message: 
Incompatible methods ("-.POSIXt", "-.POSIXct") for "-"
[1] "POSIXt"  "POSIXct"
[1] "POSIXct"
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 25 Sep 2001, Bernie McConnell wrote:

            
It's a legacy

c.POSIXct <- function(..., recursive=FALSE)
    structure(c(unlist(lapply(list(...), unclass))),
class=c("POSIXt","POSIXct"))

does the job.

  
    
#
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
Speaking of the devil... Is there any reason as.POSIXct shouldn't work
on numeric data?
Error in as.POSIXct.default(0) : Don't know how to convert `0' to class "POSIXct"
[1] "1970-01-01 01:00:00 CET"

(Discovered by trying

c.POSIXct <- function(..., recursive=FALSE)
    as.POSIXct(c(unlist(lapply(list(...), unclass))))

)
#
On 25 Sep 2001, Peter Dalgaard BSA wrote:

            
Yes, there is no way to know what it means.  Numeric data is not a date!
Yes, that works, but you need to know the meaning of the numeric vector.