Вот базовая опция R
do.call(
rbind,
Map(
function(v) data.frame(Region = v[1, ], Mean = mean(as.numeric(v[-1, ]))),
split(df, cumsum(grepl("Region\\s\\d+", df$x)))
)
)
, которая дает
Region Mean
1 Region 1 2.5
2 Region 2 1.5
3 Region 3 2.0
Data
df <- structure(list(x = c("Region 1", "1", "2", "3", "4", "Region 2",
"1", "2", "Region 3", "1", "2", "3")), class = "data.frame", row.names = c(NA,
-12L))