Getting error Data variables must be numeric or logical when doing grpstats
2 views (last 30 days)
Show older comments
here is the sample data I have; ( 6 columns) Variable called t2 with values (shown below with sample data) I am trying to get mean by condition i tried statarray = grpstats(t2,'responseTime'); getting error Error using dsgrpstats (line 266) Data variables must be numeric or logical. thanks
t2 =
157×6 table
subjID trialID condition correctChoice response responseTime
______ _______ _________ _____________ ________ ____________
1 3 1 'no' 'no' 970.53
1 5 1 'no' 'no' 717.17
1 9 1 'yes' 'no' 760.6
1 10 1 'no' 'no' 778.87
1 13 1 'yes' 'yes' 710.43
1 14 1 'yes' 'yes' 820.12
1 16 1 'yes' 'yes' 661.56
1 18 1 'yes' 'yes' 718.79
1 19 1 'no' 'no' 839.54
1 20 1 'yes' 'no' 564.83
1 1 2 'yes' 'yes' 636.25
1 2 2 'no' 'no' 565.14
1 4 2 'no' 'yes' 660.87
1 6 2 'no' 'yes' 815.26
1 7 2 'no' 'yes' 659.75
1 8 2 'yes' 'yes' 617.04
1 11 2 'yes' 'no' 617.66
1 12 2 'yes' 'yes' 865.73
1 15 2 'no' 'yes' 907.28
0 Comments
Accepted Answer
KL
on 4 Dec 2017
use varfun,
t2_mean = varfun(@mean,t2(:,[1 2 3 6]),'GroupingVariables',{'condition'})
I've indexed specific columns of the table since you have 'yes' and 'no' instead of booleans, anyway, the idea is to use condition column as grouping variable and calculate mean of all the other columns.
0 Comments
More Answers (0)
See Also
Categories
Find more on Bar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!