How to deal with this grpstat error message

 채택된 답변

the cyclist
the cyclist 2022년 5월 15일

0 개 추천

I think you want to use "mean" instead of "average" for the summary statistic.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 5월 15일

0 개 추천

You need to have braces around the average and sum, not brackets
{"average", "sum"}

댓글 수: 4

String arrays are actually allowed there.
load patients
tbl = table(Gender,Age,Weight,Smoker);
tblstats = grpstats(tbl,["Gender","Smoker"],["mean","sum"],"DataVars","Weight")
tblstats = 4×5 table
Gender Smoker GroupCount mean_Weight sum_Weight __________ ______ __________ ___________ __________ Male_0 {'Male' } false 26 180.04 4681 Male_1 {'Male' } true 21 181.14 3804 Female_0 {'Female'} false 40 130.32 5213 Female_1 {'Female'} true 13 130.92 1702
alpedhuez
alpedhuez 2022년 5월 15일
편집: alpedhuez 2022년 5월 15일
has
tblstats3 = grpstats(tbl,["Gender","Smoker"],["min","max"], ...
"DataVars","Weight")
It's easy to get muddled, because if you specify the input arguments as character arrays rather than strings, then you do need to use curly braces. (Notice the single quotes rather than the double quotes around the arguments.)
load patients
tbl = table(Gender,Age,Weight,Smoker);
tblstats = grpstats(tbl,{'Gender','Smoker'},{'mean','sum'},'DataVars','Weight')
tblstats = 4×5 table
Gender Smoker GroupCount mean_Weight sum_Weight __________ ______ __________ ___________ __________ Male_0 {'Male' } false 26 180.04 4681 Male_1 {'Male' } true 21 181.14 3804 Female_0 {'Female'} false 40 130.32 5213 Female_1 {'Female'} true 13 130.92 1702
alpedhuez
alpedhuez 2022년 5월 15일
Thank you. "You specify the input arguments as character arrays rather than strings". Will you explain a bit more?

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

카테고리

도움말 센터File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기

태그

질문:

2022년 5월 15일

댓글:

2022년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by