File: reorder.array.Rd

package info (click to toggle)
r-cran-memisc 0.99.31.8.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,136 kB
  • sloc: ansic: 5,117; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,725 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
\name{reorder.array}
\alias{reorder}
\alias{reorder.array}
\alias{reorder.matrix}
\title{Reorder an Array or Matrix}
\description{
  \code{reorder.array} reorders an array along a specified
  dimension according given names, indices or results of
  a function applied.
}
\usage{
\method{reorder}{array}(x,dim=1,names=NULL,indices=NULL,FUN=mean,...)
\method{reorder}{matrix}(x,dim=1,names=NULL,indices=NULL,FUN=mean,...)
}
\arguments{
  \item{x}{An array}
  \item{dim}{An integer specifying the dimension along which \code{x} should be ordered.}
  \item{names}{A character vector}
  \item{indices}{A numeric vector}
  \item{FUN}{A function that can be used in \code{apply(x,dim,FUN)} }
  \item{...}{further arguments, ignored.}
}
\details{
  Typical usages are
  \preformatted{
  reorder(x,dim,names)
  reorder(x,dim,indices)
  reorder(x,dim,FUN)
  }

  The result of \code{rename(x,dim,names)} is \code{x}
  reordered such that \code{dimnames(x)[[dim]]} is equal to
  the concatenation of those elements of \code{names}
  that are in \code{dimnames(x)[[dim]]} and the remaining elements
  of \code{dimnames(x)[[dim]]}.

  The result of \code{rename(x,dim,indices)} is \code{x}
  reordered along \code{dim} according to \code{indices}.

  The result of \code{rename(x,dim,FUN)} is \code{x}
  reordered along \code{dim} according to \code{order(apply(x,dim,FUN))}.
  
}

\value{
  The reordered object \code{x}.
}
\seealso{
  The default method of \code{\link[stats:reorder.factor]{reorder}} in package \code{stats}.
}
\examples{
  (M <- matrix(rnorm(n=25),5,5,dimnames=list(LETTERS[1:5],letters[1:5])))
  reorder(M,dim=1,names=c("E","A"))
  reorder(M,dim=2,indices=3:1)
  reorder(M,dim=1)
  reorder(M,dim=2)
}
\keyword{manip}