Removing NaNs from imported table

Hey everyone,
I am trying to remove all the NaNs from an imported table with readtable() (.xlsx file).
i've tried using isnan() but without success.
assuming all i have right now is:
R = readtable('blabla')
how can i remove the NaNs and keep the save the new table?
  • table looks like this:
thanks for the help!

 Respuesta aceptada

Star Strider
Star Strider el 14 de En. de 2023

2 votos

See if the rmmissing function (introduced in R2016b) will do what you want.

4 comentarios

Ilay Green
Ilay Green el 14 de En. de 2023
thanks for the quick reply
rmmissing(R) is returning a 0x28 table containing no data, maybe im doing it wrong?
%% Import Data & Edit
R = readtable('Cruise_Chem_1975-2021excel.xlsx');
Y = rmmissing(R);
Y=0x28 empty table
Star Strider
Star Strider el 14 de En. de 2023
My pleasure!
I don’t have the data, so I can’t provide specific help on it. There may be NaN values in the 17 columns that did not make it into the image that have NaN or other missing values, and rmmissing will remove those rows.
Perhaps instead:
Re = R(1:2:end,:)
will do what you want.
That will create ‘Re’ (‘R’ edited) as ‘R’ with the even-numbered rows removed.
Ilay Green
Ilay Green el 14 de En. de 2023
tyvm!
made me realize it is not neccesary to use a certain function when facing a problem!
Star Strider
Star Strider el 14 de En. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Jeff Beck
Jeff Beck el 14 de En. de 2023
Editada: Jeff Beck el 14 de En. de 2023
You might try using the "MissingRule" option set to "omitrow" in readtable:
R = readtable('blabla', 'MissingRule', 'omitrow');

1 comentario

Ilay Green
Ilay Green el 14 de En. de 2023
thanks for reply!
its not working though, Star Strider solution worked well for me

Iniciar sesión para comentar.

Categorías

Preguntada:

el 14 de En. de 2023

Comentada:

el 14 de En. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by