I have a dataframe of which I put one variable into a vector.
From this vector, I would like to calculate for every 5 values mean, min and max value.
I have managed to calculate the means in this way:
means <- colMeans(matrix(df$values, nrow=5))
I know I can calculate the min and max like this:
max <- max(df$values[1:5])
min <- min(df$values[1:5])
How do I repeat this for every five values?
Edit:
Aditionally, how can I get statistic and p-value from a 1-sample t-test for each n-row?