Very sorry - I mistunderstood and confused split with index.column - totally my fault. Ok, now I've run this line:
z <- read.zoo(OrigData, index.column = 2, split = "Brand") And I am getting: Error in merge.zoo(` Plus` = c(NA, 98L, 95L, 97L, NA, 98L, 97L, 98L, NA, : series cannot be merged with non-unique index entries in a series In addition: There were 11 warnings (use warnings() to see them) And under warnings() it says: 1: In zoo(rval4[[i]], ix[[i]]) : some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique On Fri, Jul 23, 2010 at 1:13 PM, David Winsemius <dwinsem...@comcast.net> wrote: > But, but, but.... Did you read my message about the need to correctly > specify index columns? > > > The problem is that read.zoo is reading your first column as an index and > it's actually the second column that should be used for that purpose. > -- > David. > > On Jul 23, 2010, at 1:01 PM, Dimitri Liakhovitski wrote: > >> 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 >> <OrigData.csv> > > 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.