How to reshape a dataset?

2 ビュー (過去 30 日間)
Luca
Luca 2021 年 4 月 21 日
コメント済み: Luca 2021 年 4 月 25 日
Hi,
I have a dataset with stock returns for around 50 stocks, which I attached to the question. The time period is from 1962-2016. I would like to reshape it.
Right now it looks like this:
ID RET dates
10000 0.5 date1
10000 0.2 date2
10001 1 date1
.
.
.
10050 0.3 last date of stock 50
I would like it to look like this
date 1 date2 date3 .....
RET1 of stock1 RET2 of stock 1 RET3 of stock 1
REt1 of stock2 RET2 of stock 2 RET3 of stock 2
. . .
. . .
. . .
Data description
ID the id of diffrent stocks
dates daily observation
RET daily returns.
The ID variable is not really needed in the new table it just has to be 1 row.
Optimali the date variable would be the names of the column but if it is not possible it can also be the the first row.
Does someone know how to do that?
Thanks in advance

採用された回答

Sean de Wolski
Sean de Wolski 2021 年 4 月 21 日
  • Convert the dataset to the much more modern and supported table using dataset2table.
  • Look at unstack()
  1 件のコメント
Luca
Luca 2021 年 4 月 25 日
Thank you it worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by