rbindΒΆ

rbind combines 2 or more SparkDataFrames by rows.

Syntax:

  • rbind(df1, df2, ...)

Parameters:

  • df1: Any SparkDataFrame
  • df2: Any SparkDataFrame

Output:

  • SparkDataFrame
require(SparkR)

# Create 3 SparkDataFrames
smallDF <- createDataFrame(data.frame(name = c("Mouse", "Rabbit", "Bird"),
                                                count = c(3, 5, 4)))
mediumDF <- createDataFrame(data.frame(name = c("Goat", "Zebra", "Horse"),
                                                 count = c(1, 4, 2)))
bigDF <- createDataFrame(data.frame(name = c("Elephant", "Buffalo"),
                                                count = c(1, 2)))

# Combine rows of all 3 DFs into 1
zoo <- rbind(smallDF, mediumDF, bigDF)
collect(zoo)