[Solved] Matlab/Excel/R: Transforming an unbalanced dataset depending on value of column [closed]


A solution in Matlab:

A = [1 5; 1 5; 1 6; 2 4; 2 2; 3 8; 3 4];

nMaxDays = max(A(:, 1));
nMaxSamples = max(accumarray(A(:, 1), 1));

mnSamplesMatrix = nan(nMaxSamples, nMaxDays);

for (nDay = unique(A(:, 1))')
   vnThisDay = A(A(:, 1) == nDay, 2);
   mnSamplesMatrix(1:numel(vnThisDay), nDay) = vnThisDay;
end

0

solved Matlab/Excel/R: Transforming an unbalanced dataset depending on value of column [closed]