Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Summary statistics organized by group

returns
a table or dataset array with the means for the data groups specified
in `statarray`

= grpstats(`tbl`

,`groupvar`

)`tbl`

determined by the values of the grouping
variable or variables specified in `groupvar`

.

If there is a single grouping variable, then there is a row in

`statarray`

for each value of the grouping variable.`grpstats`

sorts the groups by order of appearance (if the grouping variable is a character array), in ascending numeric order (if the grouping variable is numeric), or in order of the levels (if the grouping variable is categorical).If

`groupvar`

is a cell array of character vectors containing multiple grouping variable names, or a vector of column numbers, then there is a row in`statarray`

for each observed unique combination of values of the grouping variables.`grpstats`

sorts the groups by the values of the first grouping variable, then the second grouping variable, and so on.If any variables in

`tbl`

(other than those specified in`groupvar`

) are not numeric or logical arrays, then you must specify the names or column numbers of the numeric and logical variables for which you want to calculate means using the name-value pair argument,`DataVars`

.

returns
the group values for the summary statistics types specified in `statarray`

= grpstats(`tbl`

,`groupvar`

,`whichstats`

)`whichstats`

.

uses
additional options specified by one or more `statarray`

= grpstats(`tbl`

,`groupvar`

,`whichstats`

,`Name,Value`

)`Name,Value`

pair
arguments.

returns
a column vector or matrix with the means of the groups of the data
in the matrix or vector `means`

= grpstats(`X`

,`group`

)`X`

determined by the values
of the grouping variable or variables, `group`

.
The rows of `means`

correspond to the grouping variable
values.

If there is a single grouping variable, then there is a row in

`means`

for each value of the grouping variable.`grpstats`

sorts the groups by order of appearance (if the grouping variable is a character array), in ascending numeric order (if the grouping variable is numeric), or in order of the levels (if the grouping variable is categorical).If

`group`

is a cell array of grouping variables, then there is a row in`means`

for each observed unique combination of values of the grouping variables.`grpstats`

sorts the groups by the values of the first grouping variable, then the second grouping variable, and so on.If

`X`

is a matrix, then`means`

is a matrix with the same number of columns as`X`

. Each column of`means`

has the group means for the corresponding column of`X`

.

`[`

returns
column vectors or arrays with group values for the summary statistic
types specified in `stats1,...,statsN`

] = grpstats(`X`

,`group`

,`whichstats`

)`whichstats`

.

`[`

specifies
the significance level for confidence and prediction intervals.`stats1,...,statsN`

] = grpstats(`X`

,`group`

,`whichstats`

,'Alpha',`alpha`

)

`grpstats(`

plots
the means of the groups of data in the vector or matrix `X`

,`group`

,`alpha`

)`X`

determined
by the values of the grouping variable, `group`

.
The grouping variable values are on the horizontal plot axis. Each
group mean has 100×(1 – `alpha`

)% confidence
intervals.

If

`X`

is a matrix, then`grpstats`

plots the means and confidence intervals for each column of`X`

.If

`group`

is a cell array of grouping variables, then`grpstats`

plots the means and confidence intervals for the groups of data in`X`

determined by the unique combinations of values of the grouping variables. For example, if there are two grouping variables, each with two values, there are four possible combinations of grouping variable values. The plot includes only the combinations of values that exist in the input grouping variables (not all possible combinations).

Was this topic helpful?