Is it possible to join tables with different variables and sizes by filling/padding the missing variables and rows with NaN or similar?

21 visualizaciones (últimos 30 días)
I have 4 tables that I woulk like to merge/join together into 1 large table. The 4 tables have mostly the same variables, but also a few unique ones for each table. They are also of differing sizes.
Is there a way to join/merge them by padding each table with the missing variables and rows (with NaN or 999 or something like that) so that they are able to be joined?
I've attached a few small subsets of the 4 tables in a .mat file.
  4 comentarios

Iniciar sesión para comentar.

Respuestas (1)

John Navarro
John Navarro el 10 de Jun. de 2020
Editada: John Navarro el 10 de Jun. de 2020
C = outerjoin(A,B,'Keys',{'Common Variable'},'MergeKeys',true)
% Where A and B are the corresponding Tables to merge.
Then you conbine C with the following Table. And so on.
In other words, you take two tables and make one of them. Next, you repeat the process until you became all your Tables in one.
BUT, It wont work if you use the automatic code that is generated by the Task option in the live script.
C = outerjoin(A,B,'Type','left','Keys',{'Country'},'MergeKeys',true)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by