table

Methods

Method Reference: table.ismissing

table: TF = ismissing (tbl)

table: TF = ismissing (tbl, indicator)

table: TF = ismissing (…, 'OutputFormat', outFmt)

Find missing values in table.

TF = ismissing (tbl) returns a logical array, TF, with any true values corresponding to missing elements in the input table tbl.

Missing values are defined according to the data type of each variable in tbl:

  • NaN - double, single, duration and calendarDuration
  • NaT - datetime
  • <missing> - string
  • <undefined> - categorical
  • {''} - cell arrays of character vectors
  • '' - character arrays

TF = ismissing (tbl, indicator) also returns a logical array, TF, with any true values corresponding to elements in the input table tbl, which are equal to the values in indicator. When specifying an indicator, all default missing values are ignored. If you want to keep them, you need to define them in indicator.

indicator can be either a vector of specific data type, in which case all other data types in table tbl are ignored, or a cell array containing mixed types of data types, in which case they match the data types of the variables in table tbl.

A nested table variable is never missing, whatever it holds, with or without indicator, as in MATLAB.

Besides the explicit data type match between indicator and tbl, the following additional data types matches apply.

  • double indicators match numeric and logical variables.
  • single, integer, and logical indicators match variables of their own class and double variables. Any other numeric or logical variable is not matched, and it is not an error.
  • char and cellstr indicators match string variables.
  • char, cellstr, and string indicators match categorical variables, as categorical.ismissing reads them: an empty or blank character vector matches <undefined> elements, while strings match category names only, so neither "" nor <missing> matches <undefined>; missing does.
  • missing, alone or as an element of a cell array indicator, matches the standard missing values of every variable, in addition to any other values in indicator.
  • calendarDuration indicators match calendarDuration variables, as calendarDuration.ismissing does; MATLAB accepts no calendarDuration indicator, so this is an Octave extension.

The output array TF has the same size as the input table tbl.

TF = ismissing (…, 'OutputFormat', outFmt) specifies whether TF is returned as a logical array or as a table, which maintains the variable names and all other information of the input table tbl. Specifying outFmt as 'logical' (default) returns a logical array. Specifying outFmt as 'tabular' returns a table.

Source Code: table

Where anymissing gives a single yes/no, ismissing locates every gap, returning a logical array the size of the table with one flag per element. It recognises the missing value proper to each type at once.

 Name = string ({'Li'; 'Diaz'; 'Brown'});
 Age = [38; NaN; 40];
 Grade = categorical ({'A'; 'B'; ''});
 Visit = datetime (2024, 1, [5; NaN; 7]);
 T = table (Name, Age, Grade, Visit)
T =
  3x4 table

     Name      Age       Grade          Visit       
    _______    ___    ___________    ___________    

    "Li"        38              A    05-Jan-2024    
    "Diaz"     NaN              B            NaT    
    "Brown"     40    <undefined>    07-Jan-2024
 ismissing (T)
ans =

  0  0  0  0
  0  1  0  1
  0  0  1  0

Pass an indicator to also treat specific sentinel values as missing.

 ismissing (table ([1; -99; 3]), -99)
ans =

  0
  1
  0