# How can I use DeleteMissing[] to delete “complicated rules” from a matrix

The following works as intended:

DeleteMissing[{{a, 1}, {b, 2}, {c, Missing[]}, {d, 4}, {e,
Missing[]}, {f, 5}}, 1, 1]
DeleteMissing[{a -> 1, b -> Missing[], c -> 3, d -> Missing[]}]


However, an analogous code below does not work.

DeleteMissing[{{a, 1} -> bir, {b, 2} -> iki, {c, Missing[]} ->
uc, {d, 4} -> dort, {e, Missing[]} -> bes, {f, 5} -> alti}, 1, 1]


which is supposed to give me:

{{a, 1} -> bir, {b, 2} -> iki, {d, 4} ->dort,  {f, 5} -> alti}


Why?

Use All as the third argument in DeleteMissing:

DeleteMissing[{{a, 1} -> bir, {b, 2} -> iki, {c, Missing[]} -> uc,
{d, 4} -> dort, {e, Missing[]} -> bes, {f, 5} -> alti}, 1, All]


{{a, 1} -> bir, {b, 2} -> iki, {d, 4} -> dort, {f, 5} -> alti}

DeleteMissing[{{a, 1} -> bir, {b, 2} -> iki, {{{{c, Missing[]}}}} -> uc,
{d, 4} -> dort, {e, foo[{{bar@{Missing[]}}}]} -> bes, {f, 5} ->  alti}, 1, All]


{{a, 1} -> bir, {b, 2} -> iki, {d, 4} -> dort, {f, 5} -> alti}

• I noticed that when I import data from Excel, texts such as Missing[] or na are imported as String and hence the above code does not work for strings (?), though it gives the right result for my question which does not have any string. – Tugrul Temel Jan 19 at 18:51
• @TugrulTemel, you can replace "Missing[]" with Missing[] before you use DeleteMissing; i.e., DeleteMissing[ Replace[importeddata, "Missing[]" -> Missing[], All], 1, All]. Alternatively, you can use Select[FreeQ["Missing[]" | _Missing]][importeddata] – kglr Jan 19 at 19:06