[R] Problems with weekday extraction from zoo objects

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Sat Jun 24 00:04:51 CEST 2006


On Fri, 23 Jun 2006 16:12:27 -0500 Kerpel, John wrote:

> > SP500<-read.zoo("SP500.csv", sep = ",")
> Error in read.zoo("SP500.csv", sep = ",") : 
>         index contains NAs

Well, there are two problems with this: 1. the CSV is not
comma-separated (despite its siffix) and 2. the date format should be
specified.

> First ten records of SP500.csv:
> 
> Date		Open	High	Low	Close
> Volume	Adj. Close*
                ^^^^^^^^^^^
and I changed this name to "Adj.Close" which gives a syntactically
valid name in R.

Then I successfully employed:
  SP500 <- read.zoo("SP500.csv", format = "%d-%b-%y", header = TRUE)
  DGS10 <- read.zoo("DGS10.csv", format = "%m/%d/%Y", header = TRUE)
and then
  weekdays(time(SP500))
  weekdays(time(DGS10))

Z



More information about the R-help mailing list