[R] Averaging uneven measurements by time with uneven numbers of measurements

Adele_Thompson at cargill.com Adele_Thompson at cargill.com
Fri May 6 22:23:40 CEST 2011


I figured out a poor way to do what I want.
meas<-runif(30)
times<-sort(runif(30))

timesdec<-seq(0,1,0.2)
ltim<-length(timesdec)
storing<-rep(0,ltim)

for (i in 1:ltim) {
if (i=1) {rowstart=1} else {rowstart<-findInterval(timesdec[i-1],times)+1}
rowfinal<-findInterval(timesdec[i],times)
storing[i]<-mean(meas[rowstart:rowfinal])
} #end i-for loop


-----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:
> I do not want smoothing as the data should have jumps (it is weight left in
> feeding bunker). I was thinking of maybe using a histogram-like function and
> then averaging that. Not sure if this is possible.

(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

>
> -----
> In theory, practice and theory are the same. In practice, they are not - Albert Einstein
> --
> View this message in context: http://r.789695.n4.nabble.com/Averaging-uneven-measurements-by-time-with-uneven-numbers-of-measurements-tp3499337p3499386.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list