-1

I have an xts object "data" looking like the following:

                  A
       2014-12-27 1
       2014-12-28 1
       2014-12-29 0
       2014-12-30 0
       2014-12-31 1
       2015-01-01 1
       2015-01-02 0
       2015-01-03 0
       2015-01-04 1
       2015-01-05 1

From that I want to drop all dates from a list of dates I have set up with:

       keeps<-as.vector(Table$Dates)

So I get a vector like "2000-02-03" "2000-01-20" "2000-01-05"....

What works is to keep the values for the dates in the list like :

       data[keeps, ]

However, dropping the dates does not work at all... Any Ideas?

Peterhack
  • 941
  • 4
  • 15
  • 34
  • can you provide an example of your `keeps`? – zyurnaidi May 17 '16 at 16:20
  • It is just a simple dataset with a column consisting of dates, same format as above. keeps is just the vector containing these dates. It looks like: "2016-04-21" "2016-03-10" "2016-01-21" "2015-12-03" "2015-10-22" "2015-09-03" "2015-07-16" "2015-06-03" "2015-04-15" – Peterhack May 17 '16 at 17:01
  • Been searching whole day, finally got it: Here´s the [link](http://stackoverflow.com/questions/11871572/subsetting-tricks-for-xts-in-r)! – Peterhack May 17 '16 at 18:06
  • great. if you find the solution, you can post it as an answer. – zyurnaidi May 17 '16 at 22:01

1 Answers1

0

Been searching whole day, finally got it: Here´s the link

To get the day before and and after the one of the vector I have done the following:

       Obs <- A[keeps, which.i=TRUE]
       SurroundingObs<-c(Obs-1, Obs+1)
Community
  • 1
  • 1
Peterhack
  • 941
  • 4
  • 15
  • 34