dropna

Syntax

dropna(X, [byRow=true], [thresh])

Arguments

X is a vector or matrix.

byRow is a Boolean value. The default value is true.

thresh is a positive integer.

Details

If X is a vector, delete all NULL values from X.

If X is a matrix and byRow=true, delete all rows with NULL values.

If X is a matrix and byRow=false, delete all columns with NULL values.

If thresh is specified, each row or column (as specified by byRow) in the result must have at least thresh non-NULL values.

New in version 1.30.0.

Examples

$ x=1 NULL 2 3 NULL NULL 4;
$ x.dropna();
[1,2,3,4]

$ m=matrix(1 1 1 1, 1 1 1 NULL, 1 NULL 1 NULL);
$ m;

#0

#1

#2

1

1

1

1

1

1

1

1

1

$ dropna(m);

#0

#1

#2

1

1

1

1

1

1

$ dropna(m,,2);

#0

#1

#2

1

1

1

1

1

1

1

1

$ dropna(m,false);

#0

1

1

1

1

$ dropna(m,false,3);

#0

#1

1

1

1

1

1

1

1