This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R programming help

I would like to know how I can get the average of every 60 rows in my data. The data has values for over a million rows and I would like to get the average value 60 rows at a time and compile it in a table. The data is only one column. What would the code be for that? Would I need a loop?

r

Hello syed.kabir14!

We believe that this post does not fit the main topic of this site.

This is not a bioinformatics question. Please ask stackoverflow or its statistics counterpart.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

1 answer

A) Convert your vector into a matrix with 60 columns

X <- some.vector
X.asM <- matrix(X, ncol = 60, byrow = TRUE)

B) Run rowMeans

rowMeans(X.asM)

Log in to answer this question.