sample-methods: Take a Sample from a Data Frame

Description Usage Arguments Value Examples

Description

This method is a convenience short-cut to take samples from data frames. It results in a data frame the rows of which are a sample of the complete data frame.

Usage

1
2
## S4 method for signature 'data.frame'
sample(x, size, replace = FALSE, prob = NULL)

Arguments

x

a data frame.

size

an (optional) numerical value, the sample size, defaults to the total number of rows of x.

replace

a logical value, determines whether sampling takes place with or without replacement.

prob

a vector of sampling probabities or NULL.

Value

A data frame.

Examples

1
2
for(.i in 1:4)
  print(sample(iris,5))

mutils documentation built on May 2, 2019, 4:44 p.m.