# [R] Welcome to the "R-help" mailing list

Ista Zahn izahn at psych.rochester.edu
Wed Dec 1 13:41:30 CET 2010

```Hi Bill,
Please keep the R list copied.

I don't think you've given enough information to pin down your
problem. This works:

2000-1-4     -0.038344718
2000-1-5    0.001922225
2000-1-6    0.000955702
2000-1-7    0.027090384
2000-1-10    0.011189966
2000-1-11    -0.013062569
2000-1-12    -0.004386331
2000-1-13    0.012169663
2000-1-14    0.010671321
2000-1-18    -0.006832065
2000-1-19    0.000522287
2000-1-20    -0.007095268
closeAllConnections()

attach(dat)

i=1
while(i<14){
if(weekdays(as.Date(dates[i])) == "Monday"){
print ("yes")
}
else {
print("no")

}
i=1+i

}

detach(dat)

Best,
Ista

On Tue, Nov 30, 2010 at 11:22 PM, Bill Yang <gy631223 at hotmail.com> wrote:
> Hi Ista,
> I am running into another problem now, the following is my date (example)
> 2000-1-4     -0.038344718
> 2000-1-5    0.001922225
> 2000-1-6    0.000955702
> 2000-1-7    0.027090384
> 2000-1-10    0.011189966
> 2000-1-11    -0.013062569
> 2000-1-12    -0.004386331
> 2000-1-13    0.012169663
> 2000-1-14    0.010671321
> 2000-1-18    -0.006832065
> 2000-1-19    0.000522287
> 2000-1-20    -0.007095268
> 2000-1-21    -0.002912346
> Let's focus on the dates, by using weekdays(as.Date('2010-11-30')) ==
> "Monday", im supposed to find the monday return (2nd column)
> i create an array which includes the dates, let's call it dates. then when i
> plug in the dates into the following codes
> i=1
> while(i<14){
> if(weekdays(as.Date(dates[i])) == "Monday"){
> pirnt ("yes")
> }
> else {
> print("no")
> }
> i=1+i
> }
> the programe does not run properly.......cuz im expecting to see "yes" been
> returned (there is not any "no" returned, all of them are "yes"......). i
> guess dates[i] returns "2010-1-1", but the as.Date requires '2010-1-1'..
> Bill
>
>
>> From: izahn at psych.rochester.edu
>> Date: Tue, 30 Nov 2010 21:59:50 -0500
>> Subject: Re: [R] Welcome to the "R-help" mailing list
>> To: gy631223 at hotmail.com
>> CC: r-help at r-project.org
>>
>> Hi Bill,
>> You might be working too hard. Consider:
>> > weekdays(as.Date('2010-11-30')) == "Monday"
>> [1] FALSE
>> > weekdays(as.Date('2010-11-29')) == "Monday"
>> [1] TRUE
>> >
>>
>> HTH,
>> Ista
>>
>> On Tue, Nov 30, 2010 at 9:40 PM, Bill Yang <gy631223 at hotmail.com> wrote:
>> >
>> > Hi there,
>> > I am having problem of matching string. what i want is when i type a
>> > date such as 2010-11-30, the function will return the day (monday, tuesday,
>> > wednesday, thursday, friday or staturday). then i want another function will
>> > return true if the return of the day is monday, return false if the return
>> > of the day is not monday.
>> > I already find the weekdays(as.Date('2010-11-30')) function which will
>> > tell me exactly what day its gonna be. however, i am having problem of
>> > return True or False whether or not the return day has matched.
>> > Bill
>> > P.S the following is the partial
>> > codes.if(match(weekdays(as.Date('2010-11-30'), "Monday")==1){print("yes")}
>> >
>> >
>> >
>> > r-help at r-project.org
>> >> Subject: Welcome to the "R-help" mailing list
>> >> From: r-help-request at r-project.org
>> >> To: gy631223 at hotmail.com
>> >> Date: Wed, 1 Dec 2010 03:34:01 +0100
>> >>
>> >> Welcome to the R-help at r-project.org mailing list!
>> >>
>> >> To post to this list, send your email to:
>> >>
>> >>   r-help at r-project.org
>> >>
>> >> General information about the mailing list is at:
>> >>
>> >>   https://stat.ethz.ch/mailman/listinfo/r-help
>> >>
>> >> If you ever want to unsubscribe or change your options (eg, switch to
>> >> or from digest mode, change your password, etc.), visit your
>> >> subscription page at:
>> >>
>> >>   https://stat.ethz.ch/mailman/options/r-help/gy631223%40hotmail.com
>> >>
>> >> You can also make such adjustments via email by sending a message to:
>> >>
>> >>   R-help-request at r-project.org
>> >>
>> >> with the word `help' in the subject or body (don't include the
>> >> quotes), and you will get back a message with instructions.
>> >>
>> >> the password, itself) or to unsubscribe.  It is:
>> >>
>> >>   8711208752
>> >>
>> >> Normally, Mailman will remind you of your r-project.org mailing list
>> >> passwords once every month, although you can disable this if you
>> >> prefer.  This reminder will also include instructions on how to
>> >> unsubscribe or change your account options.  There is also a button on
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Ista Zahn
>> University of Rochester
>> Department of Clinical and Social Psychology
>> http://yourpsyche.org
>

--
Ista Zahn