sample,DataFrame,logical,numeric-method {SparkR}R Documentation

Sample

Description

Return a sampled subset of this DataFrame using a random seed.

Usage

## S4 method for signature 'DataFrame,logical,numeric'
sample(x, withReplacement, fraction)

## S4 method for signature 'DataFrame,logical,numeric'
sample_frac(x, withReplacement, fraction)

sample(x, withReplacement, fraction, seed)

sample_frac(x, withReplacement, fraction, seed)

Arguments

x

A SparkSQL DataFrame

withReplacement

Sampling with replacement or not

fraction

The (rough) sample target fraction

Examples

## Not run: 
##D sc <- sparkR.init()
##D sqlContext <- sparkRSQL.init(sc)
##D path <- "path/to/file.json"
##D df <- jsonFile(sqlContext, path)
##D collect(sample(df, FALSE, 0.5))
##D collect(sample(df, TRUE, 0.5))
## End(Not run)

[Package SparkR version 1.5.0 Index]