Given a vector of numeric of length n, I need to find segments that are >= 0.2, 
compute the average of individual segments, and replace the original values in 
each segment by their corresponding averages. 
 
For example, there are three segments that are >= 0.2, the average of 1st 
segment is 0.3, 2nd is 0.5, and the 3rd is 0.5333333
 
> c(0.3,0.3,0.3,0.1,0.1,0.5,0.5,0.5,0.5,0.15,0.15,0.3,0.5,0.8) [1] 0.30 0.30 
> 0.30 0.10 0.10 0.50 0.50 0.50 0.50 0.15 0.15 0.30 0.50 0.80> m >= 0.2 [1]  
> TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE[13]  
> TRUE  TRUE
 
_________________________________________________________________


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to