Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: add sorting option in reshape long to wide transformation #1646

Open
aborruso opened this issue Sep 7, 2024 · 1 comment

Comments

@aborruso
Copy link
Contributor

aborruso commented Sep 7, 2024

Dear @johnkerl ,
if I have

i,k,v
0,1,24.6659732638166
0,2,0.0771928403914854
0,3,17.1480573249446
0,4,4.58986335417567
0,5,54.8231067125631
1,0,1.11373416732727
1,2,650.147498986054
1,3,410.298565685827
1,4,1.72819356852476
1,5,9.43866767144718
2,0,0.000744447881092356
2,1,3796.81481074326
2,3,11032.9065659285
2,4,123.985540231058
2,5,197.189275372119
3,0,0.333937791717926
3,1,2403.31993964283
3,2,27512.0684265086
3,4,102.786833201422
3,5,224.520532630013
4,0,0.0334475453616899
4,1,0.0732440869183646
4,2,27.1453052119393
4,3,40.6457880530668
4,5,317.415260872447
5,0,0.155052216785343
5,1,34.9688187932276
5,2,6.86480543048321
5,3,24.5582674726038
5,4,42.0338516988724

and I run mlr --c2p --barred then reshape -s k,v then unsparsify input.csv I get

+---+--------------------+--------------------+------------------+------------------+------------------+----------------------+
| i | 1                  | 2                  | 3                | 4                | 5                | 0                    |
+---+--------------------+--------------------+------------------+------------------+------------------+----------------------+
| 0 | 24.6659732638166   | 0.0771928403914854 | 17.1480573249446 | 4.58986335417567 | 54.8231067125631 |                      |
| 1 |                    | 650.147498986054   | 410.298565685827 | 1.72819356852476 | 9.43866767144718 | 1.11373416732727     |
| 2 | 3796.81481074326   |                    | 11032.9065659285 | 123.985540231058 | 197.189275372119 | 0.000744447881092356 |
| 3 | 2403.31993964283   | 27512.0684265086   |                  | 102.786833201422 | 224.520532630013 | 0.333937791717926    |
| 4 | 0.0732440869183646 | 27.1453052119393   | 40.6457880530668 |                  | 317.415260872447 | 0.0334475453616899   |
| 5 | 34.9688187932276   | 6.86480543048321   | 24.5582674726038 | 42.0338516988724 |                  | 0.155052216785343    |
+---+--------------------+--------------------+------------------+------------------+------------------+----------------------+

The fields order is FIFO, and then I have 1,2,3,4,5,0 order.

It would be great to have here, without the need to add another verb, the option to enter a field sorting (it could be natural sorting or ascending or descending). In example to have the option -t and -tr.

Thank you

@aborruso
Copy link
Contributor Author

aborruso commented Sep 7, 2024

Thanks to @pigreco for stimulating this idea and having made me discover this #1645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant