0

I'm trying to subset the the ZOO object x below for SaleDateTime > "2013-01-01 00:00:00.00". I've tried the attempt below, which get close but not exactly what I want. For some reason it returns records starting in 2014. The data goes all the way back to 2011 and there's plenty of values with SaleDateTime in 2013. The data has the form SaleDateTime = '2012-02-01 23:00:00.000' and SaleCount=4. This doesn't seem like it should be that tricky. I would definitely appreciate advice.

x<-zoo(Value$SalesCount, order.by=Value$SaleDateTime)

Attempt 1

 vv<-subset(x, index(x)>=as.Date("2013-01-01 00:00:00.000"))

Warning message: In eval(expr, envir, enclos) : Incompatible methods ("Ops.factor", "Ops.Date") for ">="

user3476463
  • 3,967
  • 22
  • 57
  • 117
  • Please provide a minimal, complete, and reproducible example that anyone else can simply copy and paste into their R session to run. All library statements and inputs need to be included. Cut down your data to the minimum needed to illustrate the problem if it's large and if your input is `x` then show it by displaying the output of `dput(x)` in your question. See [mcve] for general advice and see [How to Make a Great R Reproducible Example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for more R oriented advice on how to ask a question on SO. – G. Grothendieck Feb 21 '16 at 01:08

1 Answers1

0

Subsetting with [ using the index is one solution. Following the example:

vv <- x[index(x) >= as.Date("2013-01-01 00:00:00.000")]
jnas
  • 826
  • 10
  • 14