swh:1:snp:1d6f9c912933e835b749aef1f8077112982fe84e
Raw File
Tip revision: 85eeff77b2e878cc9dbd7659e4acbc035be93c28 authored by Hans W. Borchers on 22 September 2022, 13:50:02 UTC
version 2.4.2
Tip revision: 85eeff7
randperm.Rd
\name{randperm}
\alias{randperm}
\title{
Random Permutation
}
\description{
Generates a random permutation.
}
\usage{
randperm(a, k)
}
\arguments{
  \item{a}{integer or numeric vector of some length \code{n}.}
  \item{k}{integer, smaller as \code{a} or \code{length(a)}.}
}
\details{
  Generates one random permutation of \code{k} of the elements \code{a}, if
  \code{a} is a vector, or of \code{1:a} if \code{a} is a single integer.
}
\value{
  Vector of permuted elements of \code{a} or \code{1:a}.
}
\note{
  This behavior is different from Matlab/Octave, but does better correspond
  with the behavior of the perms() function.
}
\seealso{
\code{\link{perms}}
}
\examples{
randperm(1:6, 3)
randperm(6, 6)
randperm(11:20, 5)
randperm(seq(2, 10, by=2))
}
\keyword{ arith }
back to top