[R] FW: getting time series into r

Gabor Grothendieck ggrothendieck at gmail.com
Tue May 24 00:23:49 CEST 2011


On Mon, May 23, 2011 at 4:05 PM, Heiman, Thomas J. <theiman at mitre.org> wrote:
> Hi,
>
> I tried to attach these files before as .csv and they did not go through.. This time they are .txt files..  I am trying to get the attached following two timeseries (these are small subsets of the whole thing) into R so I can merge them using zoo.
>
> tmp <- read.table("baltimore.csv", sep = " ") ##This is timeseries 2
> z <- zoo(tmp[, 2:20], as.Date(as.character(tmp[, 1]), format = "%y %m %d"))
>
> tmp1 <- read.table("baltimorefludata.csv", sep = " ") ##This is timeseries 1
> z2 <- zoo(tmp[,2], as.Date(tmp[, 1]), format = "%m %d %y"))
>
> R is not recognizing Date or YEARMODA as dates..Any suggestions on what I am doing wrong or how to fix it would be greatly appreciated!!!
>

Try these. Note that in the second series the number of fields does
not match the number in the header so we just skip the header:

library(zoo)
z1 <- read.zoo("timeseries1sample.txt", format = "%m/%d/%Y", header = TRUE)
z2 <- read.zoo("timeseries2.txt", format = "%Y%m%d", skip = 1)


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list