asreml.asUnivariate | R Documentation

## Create a univariate data frame.

### Description

creates a univariate data frame from a multivariate style data frame.

### Usage

    asreml.asUnivariate(stack, data, response = "y",
                        traitName = "Trait", traitsWithinUnits = TRUE)

### Arguments

`stack` | a character or numeric vector specifying the columns in the multivariate data frame to be stacked, that is, the equivalent to an `rbind()`; the remaining columns are replicated. Typically, the columns to be stacked would be a series of repeated response variates from a set of subjects.
`data` | the multivariate data frame.
`response` | a character string naming the column resulting from the stack operation; default is `"y"`.
`traitName` | a character string naming the column in the output data frame that contains the (replicated) names of the variates in the `stack` argument; default is `"Trait"`.
`traitsWithinUnits` | a logical response that determines the sort order of the returned data frame. If `TRUE` (the default), the returned object is sorted as traits, that is, the column identified by `traitName`, within units, where `units` is defined as `seq(1,nrow(data))`. If `FALSE`, the order is units within `traitName`.

### Details

Data frames with multivariate responses are typically arranged with a separate column for each multivariate response. In some circumstances it may be necessary to restructure the data into a univariate style, where the individual responses are arranged in a single column and an appropriate identifying column added.

### Value

a data frame with the columns identified in `stack` concatenated into a single variate named by `response`, a column `traitName` identifying the (original) response of each observation added and the remaining columns in the input data frame replicated to length. The data frame is sorted according to `traitsWithinUnits`.

### Author(s)

David Butler

### Examples

    data(grass)
    uvg <- asreml.asUnivariate(seq(3,7),grass)