Splitting groups into seperate tables

17 views (last 30 days)
Machine Learning Enthusiast
Answered: Peter Perkins on 4 Nov 2019
I have table containing data of 25 groups (file attached).How to split data of each group into new table. The first column in attached file contains number of groups.
For instance,
Thegroup ID 8927 contains 730 (columns) x 48 rows
Itried "findgroups" and "splitapply" functions but didnt work for me.

Answers (1)

Peter Perkins
Peter Perkins on 4 Nov 2019
MLE, it's not clear what you have done, and what you want to do.
splitapply on a table is for cases when you want to apply a function that takes one input for each variable in a table. You may be seeng an error because you want to apply some function to each variable separately. You can use varfun to do that, or even easier, groupsummary, grouptransform, or groupfilter. Some of the latter three are fairly new.
>> t = readtable('data.csv');
>> groupsummary(t,“Group_ID”,@mean)
ans =
25×5 table
Group_IDGroupCountfun1_E_0000_WHfun1_E_0030_WHfun1_E_0100_WH...
____________________________________________________________...
109873075.57961.5949.756...
1151719341.55326.87298.11...
1569547139.06127.13119.25...
18581356160.29136.18118.33...
[snip]

Community Treasure Hunt

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

Start Hunting!