[R] Discretizing data rows into regular intervals
Daniel Malter
daniel at umd.edu
Sun Apr 3 05:06:51 CEST 2011
Sorry, I did not get the question because I read it too sloppily. I hope this
is not homework. You can proceed along this example:
set.seed(32345)
#Value of observation
value=rpois(60,100)
#Day of observation
day=sample(1:1080,50,replace=F)
day=sort(day)
#Assume 3 years
#Assume months have all 30 days
#For real dates, the breaks in cut()
#have to be defined properly
all.days=seq(from=1,to=1080)
quarter=cut(all.days,breaks=12)
quarter=as.factor(as.numeric(quarter))
#In which quarter is a certain observation
quarter.of.day=quarter[day]
#What's the minimum day in a quarter
min.day=tapply(day,quarter.of.day,min)
#What's the value at that day
values.at.min.day=value[which(day%in%min.day)]
hth,
daniel
--
View this message in context: http://r.789695.n4.nabble.com/Discretizing-data-rows-into-regular-intervals-tp3422921p3422975.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list