combine | R Documentation |
Take a sequence of vector, matrix or data frames and
combine into rows of a common data frame with an additional column
source
indicating the source object.
combine(..., names=NULL)
... |
vectors or matrices to combine. |
names |
character vector of names to use when creating source column. |
If there are several matrix arguments, they must all have the same
number of columns. The number of columns in the result will be one
larger than the number of columns in the component matrixes. If all
of the arguments are vectors, these are treated as single column
matrixes. In this case, the column containing the combineinated
vector data is labeled data
.
When the arguments consist of a mix of matrices and vectors the number of columns of the result is determined by the number of columns of the matrix arguments. Vectors are considered row vectors and have their values recycled or subsetted (if necessary) to achieve this length.
The source
column is created as a factor with levels
corresponding to the name of the object from which the each row was
obtained. When the names
argument is ommitted, the name of
each object is obtained from the specified argument name in the
call (if present) or from the name of the object. See below for
examples.
Gregory R. Warnes greg@warnes.net
rbind
, merge
a <- matrix(rnorm(12),ncol=4,nrow=3)
b <- 1:4
combine(a,b)
combine(x=a,b)
combine(x=a,y=b)
combine(a,b,names=c("one","two"))
c <- 1:6
combine(b,c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.