suppressPackageStartupMessages({library(dplyr)
library(data.table)})
# simulate a vector of 12,600 fish speed observations between 1 and 10
digits <- seq(1,10,1)
observations <- data.frame("fish" = sample(digits,12600, replace = TRUE))
setDT(observations)
n <- 60
observations[, mean(fish), by= (seq(nrow(observations)) - 1) %/% n]
#> seq V1
#> 1: 0 5.400000
#> 2: 1 5.016667
#> 3: 2 5.150000
#> 4: 3 5.450000
#> 5: 4 5.700000
#> ---
#> 206: 205 5.666667
#> 207: 206 5.933333
#> 208: 207 4.983333
#> 209: 208 5.816667
#> 210: 209 4.833333
Created on 2020-09-09 by the reprex package (v0.3.0)