[R] averageif and looping

2012-09-26 Thread Eko andryanto Prakasa
 haiii i want to know, is there any script in R to measure looping averageif (like in the excel) ... for example: i have a vector rowvalue 10 22 3-3 4-2 51 6-2 i want to measure the average of the vector for negative value with window

Re: [R] averageif and looping

2012-09-26 Thread Rui Barradas
Hello, Try the following. sapply(seq_len(nrow(dat) - 4), function(i){ w - window(dat$value, start = i, end = i + 4) mean(w[w 0])}) Hope this helps, Rui Barradas Em 26-09-2012 16:38, Eko andryanto Prakasa escreveu: haiii i want to know, is there any script in R to measure looping

Re: [R] averageif and looping

2012-09-26 Thread William Dunlap
tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Eko andryanto Prakasa Sent: Wednesday, September 26, 2012 8:39 AM To: r-help@R-project.org Subject: [R] averageif and looping  haiii i want to know