inner2outer
Swaps the nesting of a table whose variables are tables.
Category: Language Fundamentals > Data Types
Syntax
T2 = inner2outer(T)
Regroups the inner variables so they become the outer ones.
Description
Take a table with outer variables A and B, each a table with inner variables u and v. inner2outer returns a table with outer variables u and v, each containing the columns A and B. Rows are unchanged. It is useful to compare the same measurement across groups.
Input arguments
T- Table in which every variable is itself a table or timetable.
Output arguments
T2- Table with one variable per distinct inner variable name; each holds a table whose variables are the former outer ones.
Example
Swapping the nesting
inner = table([1; 2], [3; 4], 'VariableNames', {'u', 'v'});
other = table([5; 6], [7; 8], 'VariableNames', {'u', 'v'});
T = table(inner, other, 'VariableNames', {'A', 'B'});
T2 = inner2outer(T);
T2.u
Output
ans = 2×2 table
A B
_ _
1 5
2 6