Effacer les filtres
Effacer les filtres

Rowfun without changing the order

10 vues (au cours des 30 derniers jours)
Mia Dier
Mia Dier le 17 Jan 2021
Réponse apportée : Roee Ronkin le 18 Juil 2024 à 8:25
I want to use rowfun but I don't want the resulting outcome to be sorted according to the grouping variables that I specify. I want them to stay in their original ordering.
Or alternatively, reordering the resulting outcome as I want could also solve my problem. But as I lose the variable that I want to order my table accordingly after I get results from rowfun, I can't do that either.
  2 commentaires
dpb
dpb le 17 Jan 2021
You can use a function with multiple outputs and pass through the other variable as an additional input/output.
You can't do that with an anonymous function in rowfun however, will have to write the m-file code.
dpb
dpb le 17 Jan 2021
I didn't catch it was you asking the same question altho recognized the same issue...
The above works only for another auxiliary variable and cannot work uniquely if the auxiliary variable is not unique across the group.
Other than you could save the elements of the group in a cell array of the proper height, but there's still no ordering the output itself; just a collection of which of the auxiliary variable values are contained in the collection of the group.

Connectez-vous pour commenter.

Réponses (1)

Roee Ronkin
Roee Ronkin le 18 Juil 2024 à 8:25
How about adding another variable which is the original line number? Then u can always sort back to this order

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by