Format table with frequency of unique combination
이전 댓글 표시
I have a table T, a part of this looks like:
Code Number1 Date Number2
____ _______ __________ _______
a 1 03-02-2017 18.4191
a 1 17-02-2017 4.4187
a 1 17-02-2017 4.4187
a 1 01-05-2017 8.2921
b 2 01-05-2017 8.2921
b 1 01-05-2017 3.6584
b 2 01-05-2017 3.6584
b 1 04-01-2017 44.4493
b 1 04-01-2017 51.2154
c 1 04-01-2017 56.1046
Now I want to make a new table with the codes as columnnames, the dates as rownames and the frequency of this combination in the table. In this case it would look like:
a b c
___ ___ ___
04-1-2017 NaN 2 1
03-2-2017 1 NaN NaN
17-2-2017 2 NaN NaN
01-5-2017 1 3 NaN
I have already calculated the frequency by:
[C,~,ib] = unique(T(:,[1 3]));
Frequency = histc(ib, 1:height(C));
But how can I format this table?
- The column 'Code' is categorical and ' Date' is datetime
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!