File: permute.R

package info (click to toggle)
gtools 3.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 748 kB
  • sloc: ansic: 190; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 493 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#' Randomly Permute the Elements of a Vector
#'
#' Randomly Permute the elements of a vector
#'
#' This is simply a wrapper function for \code{\link{sample}}.
#'
#' @param x Vector of items to be permuted
#' @return Vector with the original items reordered.
#' @author Gregory R. Warnes \email{greg@@warnes.net}
#' @seealso \code{\link{sample}}
#' @keywords distribution
#' @examples
#'
#' x <- 1:10
#' permute(x)
#' @export
permute <- function(x) sample(x, size = length(x), replace = FALSE)