Hello I have a df such as
Groups COL1
G1 horse
G1 donkey
G1 unknown
G1 snake
G1 horse
G2 dog
G2 dog
G2 unknown
G2 unknown
G3 donkey
G3 dog
G4 Mule
G4 dog
G4 cat
G4 cat
G5 mule
G5 donkey
G5 mule
and a list
list_not_accepted=c("horse","donkey","mule")
so basically the idea would be to select only groups where the number of COL1 element present in list_not_accepted / number of all COL1 value <0.6.
so here :
G1
3/5 = 0.6so G1 does not passG2
0/5 = 0so G2 passesG3
1/2= 0.5so G3 passesG4
1/4 = 0.25so G4 passesG5
3/3 =1 so G5does not passe
at the end we should get a df such as :
Groups COL1
G2 dog
G2 dog
G2 unknown
G2 unknown
G3 donkey
G3 dog
G4 Mule
G4 dog
G4 cat
G4 cat
here are the data
> dput(tabl)
structure(list(Groups = c("G1", "G1", "G1", "G1", "G1", "G2",
"G2", "G2", "G2", "G3", "G3", "G4", "G4", "G4", "G4", "G5", "G5",
"G5"), COL1 = c("horse", "donkey", "unknown", "snake", "horse",
"dog", "dog", "unknown", "unknown", "donkey", "dog", "Mule",
"dog", "cat", "cat", "mule", "donkey", "mule")), row.names = c(NA,
-18L), class = "data.frame")
Does someone have an idea please ? thank you very much !