1
$\begingroup$

I created a list using IsotopeData command. There are some elements in the list which are Missing["NotAvailable"]. I want to have the only available data in the list. Here is my code:

ClearAll["Global`*"]
IsotopeData[{94, 236}, "DecayEnergies"]

which gives me

{Quantity[5867.07, "Kiloelectronvolts"], Missing["NotAvailable"], 
Missing["NotAvailable"], Quantity[-1588.01, "Kiloelectronvolts"]}

But in fact I want to have a list like:

{Quantity[5867.07, "Kiloelectronvolts"], Quantity[-1588.01, "Kiloelectronvolts"]}

How can I figure it out?

$\endgroup$
2
$\begingroup$

Your data

list = IsotopeData[{94, 236}, "DecayEnergies"]

There are many ways

list /. Missing[_] -> Nothing (* Replace all instances of a pattern       *)

DeleteMissing[list]           (* A specialized function just for that     *)

Cases[list, _Quantity]        (* Get Cases with the correct Head          *)

DeleteCases[list, _Missing]   (* Delete cases with the wrong Head         *)

Select[list, Not@*MissingQ]   (* Select cases for which MissingQ if False *)

all give

{Quantity[5867.07, "Kiloelectronvolts"], 
 Quantity[-1588.01, "Kiloelectronvolts"]}

The way to figure it out should have been to read the documentation for Missing

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ There's MissingQ, too, but I don't know how it differs from _Missing. It may be as simple as MissingQ[_Missing] := True; MissingQ[_] := False, but I honestly don't know. $\endgroup$ – rcollyer Jul 29 '18 at 17:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.