sampleCap: sampleCap

sampleCapR Documentation

sampleCap

Description

A safer version of sample with additional code so that if a sample size of n is greater than length of x, n is reduced and a reordered x is returned.

Usage

sampleCap(x, size = 500)

Arguments

x

either a vector of one or more elements from which to choose, or a positive integer. See ‘Details.’

size

a non-negative integer giving the number of items to choose.

Value

A vector of length size or original length of x if size is too larger, with elements drawn randomly from x.

Examples

x = LETTERS
#this would cause an error is normal sample
sampleCap(x, 50)
#this is equivalent to sample
sampleCap(x, 5)

jrboyd/seqtsne documentation built on Nov. 5, 2022, 6:37 a.m.