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?