[R] how to divide data by week

Özgür Asar oasar at metu.edu.tr
Sat Apr 14 07:58:17 CEST 2012


Dear Stefano,

A practical way might be as the following

R> acc<-read.table("acc.txt",header=T) #reading your data into R
R> acc.may<-acc[acc[,3]==5,] #subsetting data with respect to may
R> acc.may.order<-acc.may[order(acc.may[,4]),] #ordering with respect to day
R> mean(acc.may.order[1:7,5]) # mean of the period of day 1 to 7
R> mean(acc.may.order[8:14,5]) # mean of the period of day 8 to 15

This script is just for May and taking means needs manual manipulations.  On
the other hand, simple loops might deal with your problem such as for loop.

Best
Ozgur


-----
************************************
Ozgur ASAR

Research Assistant
Middle East Technical University
Department of Statistics
06531, Ankara Turkey
Ph: 90-312-2105309
http://www.stat.metu.edu.tr/people/assistants/ozgur/
--
View this message in context: http://r.789695.n4.nabble.com/how-to-divide-data-by-week-tp4556650p4556740.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list