flatMap {SparkR}R Documentation

Flatten results after apply a function to all elements

Description

This function return a new RDD by first applying a function to all elements of this RDD, and then flattening the results.

Usage

flatMap(X, FUN)

## S4 method for signature 'RDD,'function''
flatMap(X, FUN)

Arguments

X

The RDD to apply the transformation.

FUN

the transformation to apply on each element

Value

a new RDD created by the transformation.

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, 1:10)
##D multiplyByTwo <- flatMap(rdd, function(x) { list(x*2, x*10) })
##D collect(multiplyByTwo) # 2,20,4,40,6,60...
## End(Not run)

[Package SparkR version 0.1 Index]