Grouping Variables using rowfun Function Rearranging Order to Alphabetical
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
How does one keep the original sequencing of variables used for matching in the rowfun?
% Guillaume's Code from Prior Question
data = readtable('ML_Q_3.xlsx', 'ReadVariableNames', false);
%optionally, give better name to the variables of the table
%data.Properties.VariableNames = {'???', '????'}
data = rmmissing(data);  %get rid of empty rows
sorted = rowfun(@(v) {v}, data, 'GroupingVariables', 1);  %group column 2 by column 1
The resulting sorted names are in alphabetical order (col 1)  ['A','B','F','R','X'] .
Where I require it to be per the original ['B','F','R','X','A'] .
댓글 수: 0
채택된 답변
  Walter Roberson
      
      
 2019년 7월 24일
        unique() with 'stable' option. Take the third output and use it as the grouping for splitapply()
댓글 수: 8
  Walter Roberson
      
      
 2019년 7월 24일
				Stephen's elaboration of what I wrote is correct. You need the third of the three possible outputs  from unique() in order to use as the grouping variable for splitapply()
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!