Вы имели в виду это?После настройки вашего кода я получил ...
library(dplyr)
df %>%
mutate(diameter.cm = cut(diameter.cm, seq(range(diameter.cm)[1], range(diameter.cm)[2]+4, by=4), right = F),
height.m = cut(height.m, seq(range(height.m)[1], range(height.m)[2]+2, by=2), right = F)) %>%
group_by(diameter.cm, height.m) %>%
tally()
Вывод:
diameter.cm height.m n
1 [3,7) [52.3,54.3) 1
2 [7,11) [8.33,10.3) 3
3 [15,19) [14.3,16.3) 1
4 [19,23) [12.3,14.3) 1
5 [19,23) [16.3,18.3) 1
6 [23,27) [14.3,16.3) 1
7 [27,31) [16.3,18.3) 1
8 [43,47) [28.3,30.3) 1
Пример данных:
df <- structure(list(diameter.cm = c(3L, 19L, 27L, 22L, 9L, 10L, 24L,
44L, 17L, 10L), height.m = c(53.35, 13.37, 16.53, 17.8, 8.33,
8.76, 15.62, 30.3, 14.91, 8.93)), class = "data.frame", row.names = c(NA,
-10L))