| Line 1... |
Line 1... |
| 1 |
% File src/library/utils/man/stack.Rd
|
1 |
% File src/library/utils/man/stack.Rd
|
| 2 |
% Part of the R package, http://www.R-project.org
|
2 |
% Part of the R package, http://www.R-project.org
|
| 3 |
% Copyright 1995-2007 R Core Development Team
|
3 |
% Copyright 1995-2011 R Core Development Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{stack}
|
6 |
\name{stack}
|
| 7 |
\alias{stack}
|
7 |
\alias{stack}
|
| 8 |
\alias{stack.default}
|
8 |
\alias{stack.default}
|
| Line 24... |
Line 24... |
| 24 |
unstack(x, \dots)
|
24 |
unstack(x, \dots)
|
| 25 |
\method{unstack}{default}(x, form, \dots)
|
25 |
\method{unstack}{default}(x, form, \dots)
|
| 26 |
\method{unstack}{data.frame}(x, form, \dots)
|
26 |
\method{unstack}{data.frame}(x, form, \dots)
|
| 27 |
}
|
27 |
}
|
| 28 |
\arguments{
|
28 |
\arguments{
|
| 29 |
\item{x}{object to be stacked or unstacked}
|
29 |
\item{x}{a list or data frame to be stacked or unstacked.}
|
| 30 |
\item{select}{expression, indicating variables to select from a
|
30 |
\item{select}{an expression, indicating which variable(s) to select from a
|
| 31 |
data frame}
|
31 |
data frame.}
|
| 32 |
\item{form}{a two-sided formula whose left side evaluates to the
|
32 |
\item{form}{a two-sided formula whose left side evaluates to the
|
| 33 |
vector to be unstacked and whose right side evaluates to the
|
33 |
vector to be unstacked and whose right side evaluates to the
|
| 34 |
indicator of the groups to create. Defaults to \code{formula(x)}
|
34 |
indicator of the groups to create. Defaults to \code{formula(x)}
|
| 35 |
in \code{unstack.data.frame}.}
|
35 |
in the data frame method for \code{unstack}.}
|
| 36 |
\item{\dots}{further arguments passed to or from other methods.}
|
36 |
\item{\dots}{further arguments passed to or from other methods.}
|
| 37 |
}
|
37 |
}
|
| 38 |
\details{
|
38 |
\details{
|
| 39 |
The \code{stack} function is used to transform data available as
|
39 |
The \code{stack} function is used to transform data available as
|
| 40 |
separate columns in a data frame or list into a single column that can
|
40 |
separate columns in a data frame or list into a single column that can
|
| 41 |
be used in an analysis of variance model or other linear model. The
|
41 |
be used in an analysis of variance model or other linear model. The
|
| 42 |
\code{unstack} function reverses this operation.
|
42 |
\code{unstack} function reverses this operation.
|
| - |
|
43 |
|
| - |
|
44 |
Note that \code{stack} applies to \emph{vectors} (as determined by
|
| - |
|
45 |
\code{\link{is.vector}}): non-vector columns (e.g., factors) will be
|
| - |
|
46 |
ignored. Where vectors of different types are selected they are
|
| - |
|
47 |
concatenated by \code{\link{unlist}} whose help page explains how the
|
| - |
|
48 |
type of the result is chosen.
|
| - |
|
49 |
|
| - |
|
50 |
These functions are generic: the supplied methods handle data frames
|
| - |
|
51 |
and objects coercible to lists by \code{\link{as.list}}.
|
| 43 |
}
|
52 |
}
|
| - |
|
53 |
|
| 44 |
\value{
|
54 |
\value{
|
| 45 |
\code{unstack} produces a list of columns according to the formula
|
55 |
\code{unstack} produces a list of columns according to the formula
|
| 46 |
\code{form}. If all the columns have the same length, the resulting
|
56 |
\code{form}. If all the columns have the same length, the resulting
|
| 47 |
list is coerced to a data frame.
|
57 |
list is coerced to a data frame.
|
| 48 |
|
58 |
|
| 49 |
\code{stack} produces a data frame with two columns
|
59 |
\code{stack} produces a data frame with two columns:
|
| 50 |
\item{values}{the result of concatenating the selected vectors in
|
60 |
\item{values}{the result of concatenating the selected vectors in
|
| 51 |
\code{x}}
|
61 |
\code{x}.}
|
| 52 |
\item{ind}{a factor indicating from which vector in \code{x} the
|
62 |
\item{ind}{a factor indicating from which vector in \code{x} the
|
| 53 |
observation originated}
|
63 |
observation originated.}
|
| 54 |
}
|
64 |
}
|
| 55 |
\author{Douglas Bates}
|
65 |
\author{Douglas Bates}
|
| 56 |
\seealso{
|
66 |
\seealso{
|
| 57 |
\code{\link{lm}}, \code{\link{reshape}}
|
67 |
\code{\link{lm}}, \code{\link{reshape}}
|
| 58 |
}
|
68 |
}
|