# grouptransform

Transform by group

## Syntax

## Description

### Table Data

returns transformed data in the place of the nongrouping variables in table or
timetable `G`

= grouptransform(`T`

,`groupvars`

,`method`

)`T`

. The group-wise computations in
`method`

are applied to each nongrouping variable. Groups
are defined by rows in the variables in `groupvars`

that have
the same unique combination of values. For example, ```
G =
grouptransform(T,"HealthStatus","norm")
```

normalizes the data in
`T`

by health status using the 2-norm.

specifies to bin rows in `G`

= grouptransform(`T`

,`groupvars`

,`groupbins`

,`method`

)`groupvars`

according to binning
scheme `groupbins`

prior to grouping and appends the bins to
the output table as additional variables. For example, ```
G =
grouptransform(T,"SaleDate","year","rescale")
```

bins by sale year
and scales the data in `T`

to the range [0, 1].

specifies additional properties using one or more name-value arguments for any
of the previous syntaxes. For example, `G`

= grouptransform(___,`Name,Value`

)```
G =
grouptransform(T,"Temp","linearfill","ReplaceValues",false)
```

appends the filled data as an additional variable of `T`

instead of replacing the nongrouping variables.

### Array Data

returns transformed data in the place of column vectors in the input vector or
matrix `B`

= grouptransform(`A`

,`groupvars`

,`method`

)`A`

. The group-wise computations in
`method`

are applied to all column vectors in
`A`

. Groups are defined by rows in the column vectors in
`groupvars`

that have the same unique combination of
values.

specifies additional properties using one or more name-value arguments for
either of the previous syntaxes for an input array.`B`

= grouptransform(___,`Name,Value`

)

## Examples

## Input Arguments

## Output Arguments

## Tips

When making many calls to

`grouptransform`

, consider converting grouping variables to type`categorical`

or`logical`

when possible for improved performance. For example, if you have a string array grouping variable (such as`HealthStatus`

with elements`"Poor"`

,`"Fair"`

,`"Good"`

, and`"Excellent"`

), you can convert it to a categorical variable using the command`categorical(HealthStatus)`

.

## Extended Capabilities

## Version History

**Introduced in R2018b**

## See Also

### Functions

`groupsummary`

|`groupfilter`

|`groupcounts`

|`findgroups`

|`splitapply`

|`discretize`

|`varfun`

|`rowfun`