[R] fridays date to date

Greg Snow 538280 at gmail.com
Sat Mar 3 01:12:53 CET 2012


If you know that your first date is a Friday then you can use seq with
by="7 day", then you don't need to post filter the vector.

On Thu, Mar 1, 2012 at 1:40 PM, Ben quant <ccquant at gmail.com> wrote:
> Great thanks!
>
> ben
>
> On Thu, Mar 1, 2012 at 1:30 PM, Marc Schwartz <marc_schwartz at me.com> wrote:
>
>> On Mar 1, 2012, at 2:02 PM, Ben quant wrote:
>>
>> > Hello,
>> >
>> > How do I get the dates of all Fridays between two dates?
>> >
>> > thanks,
>> >
>> > Ben
>>
>>
>> Days <- seq(from = as.Date("2012-03-01"),
>>            to = as.Date("2012-07-31"),
>>            by = "day")
>>
>> > str(Days)
>>  Date[1:153], format: "2012-03-01" "2012-03-02" "2012-03-03" "2012-03-04"
>> ...
>>
>> # See ?weekdays
>>
>> > Days[weekdays(Days) == "Friday"]
>>  [1] "2012-03-02" "2012-03-09" "2012-03-16" "2012-03-23" "2012-03-30"
>>  [6] "2012-04-06" "2012-04-13" "2012-04-20" "2012-04-27" "2012-05-04"
>> [11] "2012-05-11" "2012-05-18" "2012-05-25" "2012-06-01" "2012-06-08"
>> [16] "2012-06-15" "2012-06-22" "2012-06-29" "2012-07-06" "2012-07-13"
>> [21] "2012-07-20" "2012-07-27"
>>
>> HTH,
>>
>> Marc Schwartz
>>
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list