Suppose you have a tibble t, with factor variable Fac with 2levels and character variable Var with 6 different string values. I want to filter unique options for each factor (A, B) such that only the value that is in majority (in this case "foo" for A & "bar" for B) for each factor remains. Think of the other values as errors. You can't filter them out simply by name(my original dataset has way too many options for it to be considered a clean solution). At the end, you should be able to group_by & summarize by Fac and get unique Var for each Fac.
t = tibble(Fac = as.factor(c(rep("A", 6), rep("B", 6))), Var = c(rep("foo", 4), "fii", "fa", "bor", rep("bar", 4), "bat"))
I found out, that I am able to come up only with "dirty" solutions (such as creating intermediate summaries etc.) but clean solution eludes me.
What would be your tidyverse solution?