Selecting Specific Dates in R

后端 未结 2 1716
被撕碎了的回忆
被撕碎了的回忆 2021-01-28 05:49

I am wondering how to create a subset of data in R based on a list of dates, rather than by a date range.

For example, I have the following data set data wh

相关标签:
2条回答
  • 2021-01-28 06:12

    Lets assume your breezedate list looks like this and data$date is simple string:

      breezedate <- as.Date(c("2009-09-06", "2009-10-01"))
    

    This is probably want you want:

      breezedays <- data[as.Date(data$date, '%m/%d/%Y') %in% breezedate]
    
    0 讨论(0)
  • 2021-01-28 06:25

    The intersect() function (docs) will allow you to compare one data frame to another and return those records that are the same.

    To use, run the following:

    breezedays <- intersect(data$date,breezedate) # returns into breezedays all records that are shared between data$date and breezedate
    
    0 讨论(0)
提交回复
热议问题