필터 지우기
필터 지우기

Group data for location

조회 수: 3 (최근 30일)
Sarah Yun
Sarah Yun 2019년 12월 28일
댓글: Walter Roberson 2019년 12월 29일
Hello,
I have sales data column for 3 indepedent stores, A, B and C, in 3 seperate tables
I want to merge table A and B and test if there is difference between this group and store C
So, store A + B against C
tableA
tableB
tableC
% Concatenate columns vertically
x = [A;B;C];
% the tables do not have equal rows,
% therefore must concatenate them into a single column and use a grouping variable
% How should I change next line to make group A+B and single group C
group = [1 + zeros(size(A)); 2 + zeros(size(B)); 3 + zeros(size(C))];
% How should I change next line to make group A+B and single group C?
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2019년 12월 28일
편집: Walter Roberson 2019년 12월 28일
group = [ones(size(A,1) + size(B,1),1); 2*ones(size(C,1),1)];
  댓글 수: 2
Sarah Yun
Sarah Yun 2019년 12월 28일
Hello
Is it possible to group by year?
I want to make two groups
First group for years 2000 and 2010
Second group for 2010 to 2015
Can this code do this?
Thank you.
Walter Roberson
Walter Roberson 2019년 12월 29일
group = (x.Year < 2010) + 1;
However you need to resolve the question of whether year 2010 is first group or second group.
Here, x represents the [A;B;C] combined table you made. x.Year assumes that there is a variable in the table named Year; if not then use an appropriate expression to extract the year from what you do have.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by