countByKey {SparkR}R Documentation

Count the number of elements for each key, and return the result to the master as lists of (key, count) pairs.

Description

Same as countByKey in Spark.

Usage

countByKey(rdd)

## S4 method for signature 'RDD'
countByKey(rdd)

Arguments

rdd

The RDD to count keys.

Value

list of (key, count) pairs, where count is number of each key in rdd.

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, list(c("a", 1), c("b", 1), c("a", 1)))
##D countByKey(rdd) # ("a", 2L), ("b", 1L)
## End(Not run)

[Package SparkR version 0.1 Index]