How do I select max columns values based on certain column values?
显示 更早的评论
Dear Experiences ...
i have table look like the following..
Obs-name var1 var2 var3 ...... varn seg_id
ob1 0.12 0.14 0.17 1.2 1
ob2 1.2 0.2 0.14 0.0 1
ob3 1.5 0.3 1.5 7.2 2
ob4 2.4 4.5 2.2 0.0 3
.......................................etc.
i'm doing the following procedures:
1- i eliminate the first var content .. (obs name), using the following
T = readtable('data.xls');
Tnew=T(:,2:end)
2- calculate averages of all vars values based on segment_ID
Tavg=varfun(@mean,Tnew,'GroupingVariable','Seg_ID')
- now the tavg table includes all the average values for all vars based on Seg_ID.
Now i need to select the top var values (K) for every Seg_ID (K, where k=5).. then write table includes the Seg_ID , GroupCount , top K vars names look like the following table :
seg_id(1) Group count (3) var1 name var4 name var100 name
seg_id(2) group count (5) var2 name var3 name var15 name
seg_id(3) Group count (10)var1 name var12 name varn name
...etc..
attached file include a portion of my data table.
i will thanks any one can give a solution for this issue .. thanks
3 个评论
ranjith kumar reddy P
2017-4-4
Hello,
Please be clear. what do you want to calculate the mean of every vars which you are already doing it or mean of a particular var of values which belong to same segment ID?
ahmed obaid
2017-4-4
ahmed obaid
2017-4-4
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Quantum Computing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
