Main Content

rmmissing

remove missing entries

Description

例子

r= rmmissing(一个从数组或表中删除缺失的条目。如果一个是一个向量,然后rmmissing删除任何包含丢失数据的条目。如果一个是矩阵或表格,然后rmmissingremoves any row that contains missing data.

丢失值是根据数据类型定义的一个

  • -double,,,,single,,,,期间, 和calendarDuration

  • 纳特-约会时间

  • -string

  • <未定义>-categorical

  • ' '-char

  • {''}-细胞of character vectors

如果一个is a table, then the data type of each column defines the missing value for that column.

例子

r= rmmissing(一个,,,,暗淡指定尺寸一个进行操作。默认,rmmissingoperates along the first dimension whose size does not equal 1.

例子

r= rmmissing(___,,,,名称,价值指定使用一个或多个名称值参数删除缺失条目的其他参数。例如,您可以使用rmmissing(A,'MinNumMissing',n)去除行一个至少包含n缺少值。

例子

[[r,,,,TF] = rmmissing(___还返回与对应于行或列的逻辑向量一个被删除。

Examples

全部收缩

值并删除每个

a =[[13 NaN 6 NaN]; R = rmmissing(A)
r=1×31 3 6

从具有多种数据类型的表中删除不完整的行。

首先,创建一个表,其变量包括categorical,,,,double, 和chardata types.

a =表(分类({'';'F';'M'}),[45;32;NaN],{'';'ca';'MA'},[6051;7234;NaN],。。。'VariableNames',{'Gender''年龄''State''ID'})
a =3×4 tableGender Age State ID ___________ ___ __________ ____  45 {0x0 char} 6051 F 32 {'CA' } 7234 M NaN {'MA' } NaN

remove any row of the table that contains missing data.

r= rmmissing(一个)
r=1×4桌性别年龄状态ID ______ ___ ______ ____ ____ F 32 {'ca'} 7234

Only remove rows with missing values in the年龄或者ID表变量。

r= rmmissing(一个,,,,“ datavariables',{'年龄',,,,'ID'})
r=2×4桌Gender Age State ID ___________ ___ __________ ____  45 {0x0 char} 6051 F 32 {'CA' } 7234

一个lternatively, use the数字函数来确定数值变量来加工ate on.

r= rmmissing(一个,,,,“ datavariables',,,,@isnumeric)
r=2×4桌Gender Age State ID ___________ ___ __________ ____  45 {0x0 char} 6051 F 32 {'CA' } 7234

创建一个带有丢失数据的矩阵,然后删除包含两个或多个缺失值的任何列(第二维)。返回新的矩阵和逻辑行向量,该向量指示了哪些列一个were removed.

a =[[南南5 3 NaN 5 7 NaN 9 2; 8 9 NaN 1 4 5 6 5 NaN 5; NaN 4 9 8 7 2 4 1 NaN 3]
a =3×10Nan Nan 5 3 Nan 5 7 Nan 9 2 8 9 Nan 1 4 5 6 5 Nan 5 Nan 4 9 8 7 2 4 1 Nan 3 3
[r,tf] = rmmissing(一个,,,,2,,,,'Minnummissing',,,,2)
r=3×8nan 5 3 nan 5 7 nan 2 9 nan 1 4 5 6 5 5 4 9 8 7 2 4 1 3
TF =1x10 logical array1 0 0 0 0 0 0 0 1 0

输入参数

全部收缩

输入数据,指定为向量,矩阵,表或时间表。如果一个is atimetable, 然后rmmissing(A)removes any row of一个containing missing data and also removes the corresponding time vector element. If the time vector contains a纳特或者, 然后rmmissing(A)removes it from the time vector and also removes the corresponding row of一个

沿着操作的维度,,,,specified as 1 or 2. By default,rmmissingoperates along the first dimension whose size does not equal 1.

考虑一个m-by-n输入矩阵阵列,一个

  • rmmissing(a,1)去除行一个其中包含缺失的数据。

    rmmissing(a,1)排除

  • rmmissing(a,2)removes columns of一个其中包含缺失的数据。

    rmmissing(a,2)column removal

名称值参数

将可选的参数对Name1=Value1,...,NameN=ValueN,,,,whereName是参数名称和价值is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

Example:rmmissing(A,'DataVariables',{'Temperature','Altitude'})去除行一个that contain missing data in theTemperature或者高度variables

删除行或列所需的最小丢失条目数,指定为非负标量,默认为1。

Example:rmmissing(a,'minnummissing',6)

Table variables to operate on, specified as one of the options in this table. TheDataVariables值表示要检查缺失值的输入表的哪些变量。

Other variables in the table not specified byDataVariablespass through to the output without being examined for missing values.

选项 Description Examples
Variable name

一个character vector or scalar string specifying a single table variable name

'var1'

"Var1"

可变名称的向量

字符向量或字符串数​​组的单元格数组,其中每个元素是表变量名称

{'Var1' 'Var2'}

[["Var1" "Var2"]

Scalar or vector of variable indices

表变量指数的标量或向量

1

[[13 5]

逻辑向量

逻辑向量的元素每个对应于表变量,其中真的包括相应的变量,错误的excludes it

[true false true]

Function handle

一个功能句柄that takes a table variable as input and returns a logical scalar

@isnumeric

VARTYPE下标

一个桌子下标generated by theVARTYPE功能

vartype('数字')

Example:rmmissing(T,'DataVariables',["Var1" "Var2" "Var4"])

Output Arguments

全部收缩

Data with missing entries removed, returned as a vector, matrix, table, or timetable. The size ofrdepends on the number of removed rows or columns.

removed entry indicator, returned as a logical vector. The value 1 (真的)corresponds to rows or columns inr被删除。值0(错误的)对应于不变的行和列。方向和大小TFdepends on一个and the dimension of operation.

Data Types:逻辑

Extended Capabilities

版本历史记录

在R2016b中引入

expand all

R2022A中的行为发生了变化