Skip to content
Prev 259147 / 398502 Next

Averaging uneven measurements by time with uneven numbers of measurements

Here is an example of what I would like to do:
meas = measurements 
times = time of measurement
measf = measurements in final, reduced matrix
timesf = time of measurement in final matrix

meas<-runif(30)
times<-sort(runif(30))
inputmat<-cbind(times,meas)
names(inputmat)<-c("timef","measf")

I would then like to break the times up into 0.2 increments so the final matrix would look like this:
timef measf
0.2  <mean of meas where (time >=0) and (time<0.2)>
0.4
.
.
.
1.0

Instead of measf being the mean, it could be the last measurement taken.


-----Original Message-----
From: ehlers at ucalgary.ca [mailto:ehlers at ucalgary.ca] 
Sent: Thursday, May 05, 2011 03:58 PM
To: Thompson, Adele - Adele_Thompson at cargill.com
Cc: r-help at r-project.org
Subject: Re: [R] Averaging uneven measurements by time with uneven numbers of measurements
On 2011-05-05 14:20, Schatzi wrote:
(It would be useful to include your original request - not everyone
uses Nabble.)

Actually, averaging *is* smoothing, but I suppose your intent is, for
some reason, not to smooth across 30-minute boundaries.

Perhaps you could use findInterval() to identify which measurements to
average.

Peter Ehlers