[R] calculate a rolling mean including standard deviation

2012-12-17 Thread Tagmarie
Hello everyone, I have a data frame somewhat like this one: myframe - data.frame (Timestamp=c( 24.09.2012 06:00, 24.09.2012 07:00, 24.09.2012 08:00, 24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 24.09.2012 12:00,

Re: [R] calculate a rolling mean including standard deviation

2012-12-17 Thread Tagmarie
Now I played around in Excel for the last two hours or so and solved my problem there. I know it is not really liked here but it worked. So I do not really need your help on this problem. If anyone knows on how to do it anyway I'd be very happy though!!! Nobody taught me more about R than this

Re: [R] calculate a rolling mean including standard deviation

2012-12-17 Thread Rui Barradas
Hello, Something like this? d - myframe2$distance n - length(d) mu - rep(NA, n - 1) mu[n - 1] - m - mean(d[(n - 1):n]) s - sd(d[(n - 1):n]) ex - 0 for(i in rev(seq_len(n))[-(1:2)]){ if(d[i] m + s){ ex - 0 mu[i] - m }else{ ex - ex + 1 if(ex = 2) break