[R] read.zoo question

Gabor Grothendieck ggrothendieck at gmail.com
Mon Oct 9 04:44:14 CEST 2006


Try

read.zoo(myfile, sep = ",", FUN = as.POSIXct)

or

to.chron <- function(x) {
	s <- do.call(rbind, strsplit(format(x), " "))
	chron(dates(s[,1], format = "Y-M-D"), times(s[,2]))
}
read.zoo(myfile, sep = ",", FUN = to.chron)

depending on which class you want.

On 10/8/06, Leeds, Mark (IED) <Mark.Leeds at morganstanley.com> wrote:
> I have  comma delimited asci data with each row being in the format :
>
> 2006-01-24 02:41:24.00011,1.22930000,5,1.22950000,7
> .
> .
> .
> .
>
> and i'm trying to use read.zoo ( which is similar to read.table ) to
> read in the data. the data goes all the way out to milliseconds and  i
> can't figure out what to put for the format field. if i put nothing,
> then read.zoo gets rid of the the whole time and just keeps the date but
> i want to keep the time.  i'm sure gabor knows  but he may not be on so
> maybe someone else knows ? I've done ?format and ?read.zoo and i've read
> through the zoo article in the journal of statistical software  but i
> can't figure it out.  even if someone could point me in the right
> direction for looking ( i.e a ?whatever ) that  would be a great help.
> thanks.
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation.  Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers.  This is not research and is not from MS Research but it may refer to a research analyst/research report.  Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm.  We do not represent this is accurate or complete and we may not update this.  Past performance is not indicative of future returns.  For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls.  You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions.  We cannot guarantee that any such requests received via !
>  e-mail will be processed in a timely manner.  This communication is solely for the addressee(s) and may contain confidential information.  We do not waive confidentiality by mistransmission.  Contact me if you do not wish to receive these communications.  In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules).
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list