flatMap {SparkR} | R Documentation |
This function return a new RDD by first applying a function to all elements of this RDD, and then flattening the results.
flatMap(X, FUN) ## S4 method for signature 'RDD,'function'' flatMap(X, FUN)
X |
The RDD to apply the transformation. |
FUN |
the transformation to apply on each element |
a new RDD created by the transformation.
## 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)