Getting error Data variables must be numeric or logical when doing grpstats

2 次查看(过去 30 天)
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

采纳的回答

KL
KL 2017-12-4
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 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by