0

I tried to read my data as zoo using read.zoo function, the data include 14436 columns and the first column is in date format (yyyy-mm-dd). My code is

HFs<-read.zoo("F:/Research/Drawdown analysis/Data analysis/HF return.csv",index=1,header=TRUE,format="%Y-%m-%d")

The result is I only read the first column into R as a date index, all other values are lost. and my str(HFs) shows

    ‘zoo’ series from 1990-01-31 to 2010-02-28
      Data: logi[1:242, 0 ] 
     - attr(*, "dimnames")=List of 2
      ..$ : NULL
      ..$ : NULL
      Index:  Date[1:242], format: "1990-01-31" "1990-02-28" "1990-03-31" "1990-04-30" "1990-05-31" "1990-06-30" ...

Could anyone help to figure out the correct way to read table as zoo into R?

Thanks

Wei

  • This might help. From an example I found, to read `Daily,24 Feb 2005,2055.30,4337.00` use `tmp <- read.table("demo2.txt", sep = ",")` `z <- zoo(tmp[, 3:4], as.Date(as.character(tmp[, 2]), fo rmat="%d %b %Y"))` I think `read.zoo` is used just to read in the date in the first column. You need read.table etc for your data. – CCurtis Nov 20 '13 at 08:33
  • Please provide a [_minimal_, reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). See e.g. the `dput` function. Thanks! – Henrik Nov 20 '13 at 09:34
  • Are the fields comma-separated? If so, use the argument `sep=","` . – G. Grothendieck Nov 20 '13 at 12:59

0 Answers0