Calculate min, maximum and mean in R
<p>I have data set with 130 rows and two columns. 
I want to calculate the mean, minimum and maximum of every 5 rows of the seconds column using R. By using colMeans and the following command 
<code>rep(colMeans(matrix(data$Pb, nrow=5), na.rm=TRUE), each=5)</code> I was able to compute mean for every 5 rows. However i am not able to compute max and min since there is no built in function for the same. I tried as suggested <a href="https://stackoverflow.com/questions/9921300/r-finding-maximum-value-every-two-rows-in-each-column">here</a> for 5 rows instead of 2. However I get an error that <code>dim(X) must have a positive length.</code> Can someone please help me understand as to what should I do to fix and compute the above quantities ? My end goal is to plot min,mean, max for every 5 rows. </p>

<p>Thanks in advance.  </p>