0

I have an xts variable os and another variable called date.

head(os[,1])
        ab1   ab2
2007-07-20 103.02 96.60
2007-07-20 103.00 96.25
2007-07-20 102.70 96.25
2007-07-20 102.70 96.15
2007-07-20 102.75 96.20
2007-07-20 102.50 95.80

and

head(date)
date
2007-07-20
2007-07-21

If I use:

sum(index(os)[1]==date).  

The answer is 1, which is correct. Just comparing the first date of os.

If I compare the dates from the os like so:

sum(index(os)==date)

The answer is 0.

How is it possible?

user1177819
  • 103
  • 1
  • 3
  • 7
  • 2
    Can you add some sample data to your question so that we can have a go at solving your problem? You can edit your question and paste in the results of `dput(head(yourdataobject))` – Ben Mar 22 '13 at 08:34
  • 4
    Hi there! Please make your post reproducible by having a look at [**How to make a great reproducible example**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for us to help you. Thank you. – Arun Mar 22 '13 at 08:53
  • Any idea how to get out of this trouble – user1177819 Mar 22 '13 at 10:10
  • 1
    Please do what the other suggested before we can help you, you'll get a quick answer as it's easy. We need to make the answer useable for everybody that will come next, that's why we are asking – statquant Mar 22 '13 at 11:03
  • 2
    `sum(index(os)==date)` returns 3 for me. You need to provide a reproducible example. – Joshua Ulrich Mar 22 '13 at 19:02

0 Answers0