[R] how to calculate conditional mean?

2004-12-05 Thread Terry Mu
a data set like this: year monthdaycount 2001 11 10 2001 12 11 2004 7178 basically it is a count of of some numbers everyday through a few years now I'd like to get the mean of the count for every day.

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Gabor Grothendieck
Terry Mu muster at gmail.com writes: : : a data set like this: : : year monthdaycount : 2001 11 10 : 2001 12 11 : : 2004 7178 : : : basically it is a count of of some numbers everyday through a few

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Terry Mu
thank you, one more question: How can I list only values for given condition? for example, I want to see only data from febuary, i.e. month=2? On Sun, 5 Dec 2004 16:26:11 + (UTC), Gabor Grothendieck [EMAIL PROTECTED] wrote: Terry Mu muster at gmail.com writes: : : a data set like this:

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Terry Mu
Sorry, I didn't express my problem clearly. Your answers surely help, but it's not what I meant to ask. I'd like mean for every day in a year, i.e, mean for January 1st, 2nd, 3rd, Febuary, 1st, ..., 28th, 29th(if leap year) ... There is only one count per day, so there is no need to

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Gabor Grothendieck
Do you mean the mean for all January firsts, the mean for all January 2nds, etc.? Look up ?format in addition to the commands you looked up before: tapply(DF$count, format(Dates, %Y-%m), mean) Terry Mu muster at gmail.com writes: : : Sorry, I didn't express my problem clearly. Your

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Gabor Grothendieck
Place Dates in DF and use subset(DF, month == 2) in place of DF. I think you need to reread the Introduction to R manual since you should find this sort of question answered there. If not the pointers I gave you should get you started. Terry Mu muster at gmail.com writes: : : thank you, : :

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Gabor Grothendieck
In my previous post the format should have been %m %d. Terry Mu muster at gmail.com writes: : : thank you, : : one more question: : : How can I list only values for given condition? : for example, I want to see only data from febuary, i.e. month=2? : : On Sun, 5 Dec 2004 16:26:11 +

Re: [R] how to calculate conditional mean?

2004-12-05 Thread Terry Mu
thanks, this time it works perfectly. I use tapply(DF$count, format(Dates, '%m-%d'), mean). as Patrick mentioned. It works without as.date(). with as.date() on, it gives a result one day after the actual date. I also got subset(). Thank you all very much. I like R and will learn more. Terry