Suppose I have a list as follow:
l = {{"a", "b", "c"}, {"a", "b"}, {"a", "d", "b"}, {"a", "c", "e"}};
Now I am going to flatten it and apply Counts
to count each element:
l // Flatten // Counts
<|"a" -> 4, "b" -> 3, "c" -> 2, "d" -> 1, "e" -> 1|>
Now I want to do followings:
From the list how can I retain only sublists whose components have frequency more than 1 in the overall list
l
, namely the output should look like this:{{"a", "b", "c"}, {"a", "b"}}
as all "a"
, "b"
and "c"
have frequency above 1.
how can I delete those sublists that contain any components that have frequency 1 from
l
, namely the output should look like:{{"a", "b", "c"}, {"a", "b"}, {"a", "b"}, {"a", "c"}}