The aim is to aggregate the observation by the number of rows.
To illustrate, example data look like:
structure(list(observation = c(1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1)), class = "data.frame", row.names = c(NA,
-20L), variable.labels = structure(character(0), .Names = character(0)), codepage = 65001L)
Visually, the above is:
╔═════════════╗
║ observation ║
╠═════════════╣
║ 1 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 1 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 1 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 0 ║
╠═════════════╣
║ 1 ║
╚═════════════╝
The end goal is to aggregate by a designated number of rows (e.g., 10 in the example output below) in terms of the count of 1's and the average. The output would look like:
╔═══════╦══════╗
║ count ║ mean ║
╠═══════╬══════╣
║ 3 ║ 0.3 ║
╠═══════╬══════╣
║ 1 ║ 0.1 ║
╚═══════╩══════╝