0

I have a data frame with a range of dates as the column names and a list of stock tickers down the y axis. I then have a separate character list of dates.

I want to create a subset of the data frame if the dates in the data frame match any of the dates in the character list.

Below please find links to images of the data frame and the list of dates. I would appreciate any advice as I have not been able to find a solution.

enter image description here

enter image description here

h3rm4n
  • 4,126
  • 15
  • 21
asathe1
  • 31
  • 4
  • 3
    Posting pictures of data is not helpful. See [how to create a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). That will make it easier to help you. – MrFlick May 30 '17 at 13:01
  • Adding to the comments of @MrFlick , instead of an image, please use `dput` to create a text version of your data and paste the results into your question. If the data is too long, you can provide a sample with something like `dput(head(myData, 20))` – G5W May 30 '17 at 13:06
  • 1
    Also please review [ask] and [mcve] – G. Grothendieck May 30 '17 at 13:09

1 Answers1

2

If understand you well, you want your data's column which are on the list you put ?

I think this could work :

new_data = data[,which(colnames(data)%in%your_list)]

Tell me if this isn't what you want.

MBnnn
  • 308
  • 2
  • 13