Delete rows with NaN records
Show older comments
How can I delete rows which have NaN on one of the column.
Accepted Answer
More Answers (3)
Chris Turnes
on 7 Mar 2017
5 votes
Not that this question needed another answer, but, you can also check out the rmmissing function that was introduced in R2016b. If you combine this with standardizeMissing, you can convert your 'GNAs' strings to a standard missing indicator, and then remove the rows with rmmissing.
carmen
on 12 Mar 2012
check out the isnan() functioion. the following code looks like a workaround but it works:
A=[1 2 3;nan 4 5;nan 6 nan];
B=A(sum(isnan(A),2)==0);
B %returns the only nan-free row of A: [1 2 3]
hf
1 Comment
A=[1 2 3;nan 4 5;nan 6 nan]
B=A(sum(isnan(A),2)==0,:);
B %returns the only nan-free row of A: [1 2 3]
Manuel Aboy
on 28 Dec 2022
0 votes
mpg = mpg(~ismissing(mpg));
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!