Learn R Programming

IssueTrackeR (version 1.4.1)

sample-issues: Random Sampling

Description

Generic function for drawing a random sample from an object.

For objects of class IssuesTB, this method returns a random subset of the issues.

Usage

sample(x, size, replace = FALSE, prob = NULL)

# S3 method for IssuesTB sample(x, size = nrow(x), replace = FALSE, prob = NULL)

# S3 method for default sample(x, size, replace = FALSE, prob = NULL)

Value

  • For IssuesTB objects, an object of the same class containing the sampled issues.

  • For all other objects, the result of base::sample().

Arguments

x

An object of class IssuesTB.

size

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

replace

should sampling be with replacement?

prob

a vector of probability weights for obtaining the elements of the vector being sampled.

Details

The arguments and overall behavior are consistent with base::sample(). For details about the sampling algorithm, probability weights, and special cases, refer to the original documentation: https://stat.ethz.ch/R-manual/R-devel/library/base/html/sample.html

See Also

Examples

Run this code
path <- system.file("data_issues", package = "IssueTrackeR")
open_issues <- get_issues(
    source = "local",
    dataset_dir = path,
    dataset_name = "open_issues.yaml"
)
new_issues <- sample(open_issues, size = 5L)

Run the code above in your browser using DataLab