Unstack data from single variable into multiple variables

converts
the table or timetable, `U`

= unstack(`S`

,`vars`

,`ivar`

)`S`

, to an equivalent table
or timetable, `U`

, that is unstacked. The `unstack`

function
unstacks a single variable in `S`

, specified by `vars`

,
into multiple variables in `U`

. In general, `U`

contains
more variables, but fewer rows, than `S`

.

An indicator variable in `S`

, specified by `ivar`

,
determines which variable in `U`

contains each value
in `var`

after it is unstacked. `unstack`

treats
the remaining variables in `S`

as grouping variables.
Each unique combination of values in the grouping variables identifies
a group of rows in `S`

that will be unstacked into
a single row of `U`

.

If `S`

is a timetable, then you cannot unstack
its vector of row times, but you can specify the row times by name
as the indicator variable. You also can specify the row times as a
constant variable with the `'ConstantVariables'`

argument.
Otherwise, the `unstack`

function treats the row
times of a timetable as a grouping variable.

converts
the table or timetable `U`

= unstack(`S`

,`vars`

,`ivar`

,`Name,Value`

)`S`

with additional options
specified by one or more `Name,Value`

pair arguments.

For example, you can specify how `unstack`

converts
variables from `S`

to variables in `U`

.

Was this topic helpful?