How to retrieve a table entry using row name?
80 次查看(过去 30 天)
显示 更早的评论
The function anova returns a 3x5 table and I would like retreive the value from the row named Model and column named pValue. How do I do this? I don't know how to retreive a table entry by the row name, only by the row number.
mr = anova(lm,'summary')
0 个评论
采纳的回答
dpb
2020-4-10
It's a table; use the curlies "{}" to dereference row names to return the content of the row or regular paren's "()" to return a table:
Used example for anova to illustrate w/o your data to replicate--
load hospital
tbl = table(hospital.Age,hospital.Sex,hospital.BloodPressure(:,2), ...
'VariableNames',{'Age','Sex','BloodPressure'});
tbl.Sex = categorical(tbl.Sex);
mdl = fitlm(tbl,'BloodPressure ~ Sex + Age'); simplified model to remove nonlinear terms
>> tAnova=anova(mdl,'summary')
tAnova =
5×5 table
SumSq DF MeanSq F pValue
______ __ ______ _______ ________
Total 4757.8 99 48.059
Model 243.8 2 121.9 2.6194 0.077994
Residual 4514 97 46.537
. Lack of fit 1514 40 37.851 0.71916 0.86306
. Pure error 3000 57 52.632
>>
>> tAnova('Total',:) % retrieve Total SSQ by row name as table
ans =
1×5 table
SumSq DF MeanSq F pValue
______ __ ______ ___ ______
Total 4757.8 99 48.059 NaN NaN
>>
>> tAnova{'Total',:} % retrieve as array of values only
ans =
1.0e+03 *
4.7578 0.0990 0.0481 NaN NaN
>>
See the detailed description of addressing tables that is in the lind from "See Also" for table for all the skinny on all the ways to address tables.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!