nPr: Calculate the number of possible partial permutations of n...

View source: R/stat_funcs.R

nPrR Documentation

Calculate the number of possible partial permutations of n objects, r at a time

Description

Calculates the number of ordered arrangements in which no element occurs more than once, without the requirement of using all the elements from a given set. Also known as partial permutations or as sequences without repetition.

Usage

nPr(n, r)

Arguments

n

An integer number of elements to permute. May be a vector if r has a single element (i.e. length(r) == 1).

r

An integer subgroup size. May be a vector if n has a single element (i.e. length(n) == 1).

Details

Implements the equation

n! / (n - r)!

Value

A named vector containing the integer number of possible permutations for each value of n supplied.

Examples

  ## Not run: 
    nPr(3, 2)
    nPr(3:5, 2)
    nPr(5, 2:4)
    nPr(1:5, 3)
  
## End(Not run)

tomhopper/numbr documentation built on Nov. 5, 2022, 11:35 p.m.