In Octave I code:
T = table([10;20],{'M';'F'},'VariableNames',{'Age','Gender'},'RowNames',{'P1','P2'})
From the example on this website: https://www.mathworks.com/help/matlab/ref/table.html
And get error:
't' undefined near line 1 column 1
>> [T, L_X] = table([10;20],{'M';'F'},'VariableNames',{'Age','Gender'},'RowNames',{'P1','P2'})
error: Invalid call to table. Correct usage is:
-- [T, L_X] = table (X)
But when I change to [T, L_X] = ...
or to [T, L_X, L_Y] = ...
I get the same error. What am I doing wrong and what am I misunderstanding? What should I do to get the example right? Is this an issue of Matlab/Octave differences?
The table
data type in MATLAB is not yet implemented in Octave. There is a table
function in Octave for creating a contingency table, which is what your code is using, and is obviously not what you want.
As an alternative, you may want to check out the Dataframe package, which can provide you with similar functionality to a MATLAB table
.