I have this base
# A tibble: 15 x 5
id A B C vars
<int> <lgl> <lgl> <lgl> <chr>
1 1 FALSE TRUE FALSE team5
2 2 TRUE FALSE TRUE team9
3 3 FALSE TRUE FALSE team7
4 4 FALSE FALSE FALSE team2
5 5 TRUE TRUE TRUE team8
6 6 FALSE TRUE FALSE team2
7 7 TRUE TRUE FALSE team2
8 8 FALSE FALSE FALSE team6
9 9 TRUE TRUE TRUE team6
10 10 FALSE FALSE FALSE team7
11 11 TRUE FALSE TRUE team6
12 12 TRUE TRUE FALSE team7
13 13 FALSE TRUE TRUE team9
14 14 TRUE FALSE TRUE team1
15 15 FALSE FALSE FALSE team4
and I need to make a loop where I filter by variables A,B and C and then calculate how many unique values of vars are present after filtering.
For example, filtering by variable A would look like this
# A tibble: 7 x 5
id A B C vars
<int> <lgl> <lgl> <lgl> <chr>
1 2 TRUE FALSE TRUE team9
2 5 TRUE TRUE TRUE team8
3 7 TRUE TRUE FALSE team2
4 9 TRUE TRUE TRUE team6
5 11 TRUE FALSE TRUE team6
6 12 TRUE TRUE FALSE team7
7 14 TRUE FALSE TRUE team1
and the answer is 75% (8 teams in total and 6 are presents filtering by A)
In the case of B the answer is 75% and in C it is 50%.
I need to do it in loop and that it is applicable to bigger bases. That's why I put this tibble as an example.