[R] array question

Benilton Carvalho beniltoncarvalho at gmail.com
Wed Feb 17 18:38:14 CET 2010


you mean something along the lines of

filter(x, rep(1/4, 4))

(which you can combine with na.omit)

?

On Wed, Feb 17, 2010 at 5:18 PM, Mohsen Jafarikia <jafarikia at gmail.com> wrote:
> Hello All:
>
> If I do have:
>
> x = (2, 4, 5, 5, 6, 4, 5, 2, 1)
> y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22)
>
> I wanted to find a simple function in R which calculates the averages of X
> and Y for every 4 unit increase of Y. The results should look like:
>
> x = (4, 6, 3)               #where (2+ 4+ 5+ 5)/ 4 = 4 and ...
> y = (12, 14, 20.5)      #where (9+11.5+12.5+13)/ 4 = 12 and ...
>
> Thanks,
> Mohsen
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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