If I have a matrix or table of data,
Data = {{1, 2, 3}, {3, 4, 5}, {5, 6, 7}, {7, 8, 9}, {9, 10, 11}, {11, 12,
13}, {13, 14, 15}, {15, 16, 17}, {17, 18, 19}, {19, 20, 21}, {21,
22, 23}, {23, 24, 25}, {25, 26, 27}, {27, 28, 29}, {29, 30,
31}, {31, 32, 33}}
Is there a method of deleting or dropping a row if any column has the value defined by a list, e.g.
TestList = {1, 8 , 16, 24}
such that if any element contains one of those values then the row itself is removed?
It's achievable by using nested Select
statements where you would have a Select
for each column and test them individually against the list, using MemberQ
but that seems a little crude.
Select[Data, Intersection[TestList, #] === {} &]
? $\endgroup$Transpose[]
for that. $\endgroup$ContainsNone
and similar functions: They are really only syntactic sugar, but they make for very readable code. For instance, your row-wise requirement could be written asSelect[Data, ContainsNone[TestList]]
. $\endgroup$