Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

randomRows

Sample rows from a dataframe or matrix


Description

Sample rows from a dataframe or matrix

Usage

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

Arguments

x

a data frame or matrix

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.

Changes

Matched parameters to sample – njf, May 18, 2015

Author(s)

References

See Also

sample_n for dplyr users


stackoverflow

Stack Overflow's Greatest Hits

v0.7.0
CC BY-SA 4.0
Authors
Neal Fultz <nfultz@gmail.com> and the StackOverflow.com community
Initial release
2020-01-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.