I'm stuck trying to make a subsetting code. I want to subset/select rows of data based on the same condition across a large number of columns. So in the below example I want to select rows where any of the 'year' columns that has values greater than 1.
Data have:
ID 1970 1971 1972....2020
599 0 0 0 1
628 3 1 0 0
788 1 0 0 1
111 0 0 1 0
222 0 2 1 1
Data want:
628 3 1 0 0
222 0 2 1 1
I tried this dpylr code without success.
select <- df %>%
filter(vars(starts_with(c("1","2")), any_vars(. > 1))