Learn R Programming

GuessCompx (version 1.0.3)

GroupedSampleFracAtLeastOneSample: Fraction Sampling without empty output

Description

Sample a random proportion of the data, keeping at least one observation

Usage

GroupedSampleFracAtLeastOneSample(d_subset, prop, is.random = TRUE)

Arguments

d_subset

A dtta.frame from which a small sample is to be returned

prop

A number between 0 and 1, being the desired sampling fraction.

is.random

a boolean. If TRUE, a random sample is drawn, else it takes the head() of the data

Value

A random sample from the data, of proportion prop, but always returning at least one observation even if prop is too low.

Details

This function is designed to allow its use with group splitting or do.by methods.