What an interesting puzzle. I suppose you could do something like this. This function returns TRUE when all columns from start_col onwards are empty and FALSE if any values are found.
library(dplyr, warn.conflicts = FALSE)
library(purrr)
df <- tribble(~ col1, ~ col2, ~ col3, ~ col4, ~ col5,
1, 2, NA, NA, NA,
3, 4, 3, NA, NA)
check_for_empty_cols <- function(data, start_col) {
data %>%
select(all_of(start_col):last_col()) %>%
map(~ all(is.na(.x))) %>%
reduce(all)
}
check_for_empty_cols(df, start_col = 3)
#> [1] FALSE
check_for_empty_cols(df, start_col = 4)
#> [1] TRUE
Created on 2020-07-31 by the reprex package (v0.3.0)