VARFUN() vis a vis GROUPSUMMARY()
4 次查看(过去 30 天)
显示 更早的评论
If one uses varfun() to group a set of variables, one can set the output variable name(s) as desired -- say one has an Amount for a bunch of things and wants a total by group. It's nice to be able to label the new table variable 'Amount' as well for consistency, not being forced to use the automagically generated name.
However, if one has N groups overall but for one subsection (say a given month out of table of a year or more of data) there is no total for a given group, then one cannot get a zero total for that group for that given month; one only gets the group totals that are present. This also then creates the need to code the use of the result to handle the fact there may not be a value/variable of a given class; also a bother in not having perfectly generic code. (As a side issue, it would surely be nice to also have an option to not return the 'GrouopCounts' variable although if one is going to be forced to code around the zero case, then it has its use; I much prefer to have all the code generic instead).
Alternatively, one can use groupsummary() that has the optional input parameter to return the empty groups; but for some reason it won't let you name the output variable so one has to write another line of code to do that. WHY?
Do others find this as annoying as I; is it worthy of an enhancement request?
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!