On Sat, Nov 27, 2010 at 5:02 PM, Eduardo de Oliveira Horta <eduardo.oliveiraho...@gmail.com> wrote: > Hello! > > I have a csv file of intra-day financial data (5-min closing prices) that > looks like this: (obs - the dates are formated as day/month/year, as is > usual here in Brazil) > > Date;Time;Close > 01/09/2009;10:00;56567 > 01/09/2009;10:05;56463 > 01/09/2009;10:10;56370 > ##(goes on all day) > 01/09/2009;16:45;55771 > 01/09/2009;16:50;55823 > 01/09/2009;16:55;55814 > ##(jumps to the subsequent day) > 02/09/2009;10:00;55626 > 02/09/2009;10:05;55723 > 02/09/2009;10:10;55659 > ##(goes on all day) > 02/09/2009;16:45;55742 > 02/09/2009;16:50;55717 > 02/09/2009;16:55;55385 > ## (and so on to the next day) >
Try this: library(zoo) library(chron) f <- function(x) times(paste(x, 0, sep = ":")) z <- read.zoo(textConnection(Lines), header = TRUE, sep = ";", split = 1, index = 2, FUN = f) colnames(z) <- sub("X(..).(..).(....)", "\\3-\\2-\\1", colnames(z)) It produces a zoo object where each column is a series made up of one day. The columns are aligned by time of day so the result for the example data is the following zoo object: > z 2009-09-01 2009-09-02 10:00:00 56567 55626 10:05:00 56463 55723 10:10:00 56370 55659 16:45:00 55771 55742 16:50:00 55823 55717 16:55:00 55814 55385 -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org 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.