sampleOne: Return a random sample of size 1

Description Usage Arguments Value Examples

View source: R/saviUtilityFunctions.R

Description

The default sample function is not compatible with vectors of length 1. If the code says "sample(3:3)," sample will return a random integer between 1 and 3. The way our code is written, we would like it to return just 3. We implement the following function for that purpose.

Usage

1

Arguments

x

A vector of integers

Value

A random integer from x. If x is c(5:5), return 5.

Examples

1
2
    sampleOne(c(4:10))
    sampleOne(c(4:4))

nsimone101/savi documentation built on July 1, 2020, 4:53 a.m.