Re: [R] reading dates

About this list Date view Thread view Subject view Author view Attachment view

From: Suchandra Thapa (s-thapa-11@alumni.uchicago.edu)
Date: Thu 17 Jan 2002 - 02:26:40 EST


Message-id: <20020116092640.A14297@hepcat>

On Wed, Jan 16, 2002 at 06:31:58AM +0000, Prof Brian Ripley wrote:
> There are so many possible formats of dates that any attempt to automate
> this is bound to lead to problems.

    The date is currently in %Y-%m-%d %H:%M format.
     
> `In principle' because you need to set up as() to do the conversion (and
> that is part of the methods package and not set up out-of-the-box).

    Okay, I'm trying that but seem to be having some difficulties.
Using this:

setClass('POSIXlt', representation(sec="numeric",
                                   min="numeric",
                                   hour="numeric",
                                   mday="numeric",
                                   mon="numeric",
                                   year="numeric",
                                   wday="numeric",
                                   yday="numeric",
                                   isdst="numeric"))
setAs('POSIXlt', 'character', function(from) strptime(from, format="%Y-%m-%d %H:%M"))

allows the read.table to work and read the file in however I can't seem
to get individual dates. After running

foo <- read.table(file="output", as.is=c(T, F), colClasses=c('POSIXlt', 'double'), col.names=c('date', 'price'))

foo$date[1] gives all the second fields instead the first date.

> What's the problem with what you are doing now?
    
    Primarily that it doesn't work very well. Also I'm trying to simplify
things as much as possible so that the person the script is being written
for can understand it easily.

-- 
------------------------------------------------------------------

Suchandra S. Thapa s-thapa-11@alumni.uchicago.edu

------------------------------------------------------------------ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:11 EST