1

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?

rhermans
  • 36,518
  • 4
  • 57
  • 149
AYBRXQD
  • 1,085
  • 6
  • 16

1 Answers1

2

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

rhermans
  • 36,518
  • 4
  • 57
  • 149
  • 1
    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. – rcollyer Jul 29 '18 at 17:23