Strange, I did attach. Attaching again. Maybe the file just doesn't go through? I have:
names(OrigData): [1] "Brand" "Month" "Value" I read ?read.zoo According to that index should be the column number. I thought it should be split = 1 in my case - because I am splitting by Brand. But neither split = 1 nor split =2 work. And split ="Brand" does not work either. Why? D. On Fri, Jul 23, 2010 at 12:52 PM, David Winsemius <dwinsem...@comcast.net> wrote: > ?read.zoo > > You didn't specify the index column correctly. > On Jul 23, 2010, at 12:36 PM, Dimitri Liakhovitski wrote: > >> Hello! >> >> I have a data set similar to the data set "monthly" in the example below: >> >> >> monthly<-data.frame(month=c(20090301,20090401,20090501,20100301,20100401,20090301,20090401,20090501,20100301,20100401),monthly.value=c(100,200,300,101,201,10,20,30,11,21),market=c("Market >> A","Market A", "Market A","Market A", "Market A","Market B", "Market >> B","Market B","Market B", "Market B")) >> monthly$month<-as.character(monthly$month) >> monthly$month<-as.Date(monthly$month,"%Y%m%d") >> (monthly) >> str(monthly) >> >> >> I am trying to use read.zoo - like in 3 lines below: >> library(zoo) >> z <- read.zoo(monthly, split = "market") >> (z) >> >> With the artificially produced data set above, it works just fine. >> However, with my data it gives me an error: >> >> OrigData<-read.csv("OrigData.csv") >> OrigData$Month<-as.character(OrigData$Month) >> OrigData$Month<-as.Date(OrigData$Month,"%m/%d/%y") >> str(OrigData) >> >> ### The result of str(OrigData) is: >> 'data.frame': 440 obs. of 3 variables: >> $ Brand : Factor w/ 11 levels "aBrand","bBrand",..: >> Month :Class 'Date' num [1:440] 13514 13545 13573 13604,... >> Value: int NA NA NA 100 100 100 100 100 100 99 > > ?read.zoo > > You didn't specify the index column correctly. In this case it needs to be = > 2. > >> >> Then I try: >> z <- read.zoo(OrigData, split = "Brand") >> >> And get the error: >> Error in read.zoo(OrigData, split = "Brand") : >> index has 440 bad entries at data rows: 1 2 3 4 5 6 7 8 9 10 11 12 13 >> >> But the structure of my OrigData is exactly the same as of monthly. OK >> - OrigData always has a few NAs in "Value" coming first - but that's >> consistent for all brands. >> Any idea what might be wrong? >> Thanks a lot! >> >> Just in case -attaching the actual file. >> > No. Not attached. > > -- > > David Winsemius, MD > West Hartford, CT > > -- Dimitri Liakhovitski Ninah Consulting www.ninah.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.