Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Subset a dataframe with dynamic dates by date range in R

$
0
0

I have the dataframe below:

dates <- data.frame(rep(
  seq(as.Date('2017-01-01'), as.Date('2017-12-31'), by = 'days'), 
  times = 1))
colnames(dates)<-"day"

And I would like to subset it by the last 2 weeks. The thing is that I do not want to use something like:

dates[day>="2017-18-02"& day<="2017-05-02"]

because the dataframe will be updated over time and the last date will be changing.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>