rbind

rbind combines 2 or more SparkR DataFrames by rows.

Syntax:

  • rbind(df1, df2, ...)

Parameters:

  • df1: Any Spark R DataFrame
  • df2: Any Spark R DataFrame

Output:

  • SparkR DataFrame
# Create 3 SparkR DataFrames
smallDF <- createDataFrame(sqlContext, data.frame(name = c("Mouse", "Rabbit", "Bird"),
                                                count = c(3, 5, 4)))
mediumDF <- createDataFrame(sqlContext, data.frame(name = c("Goat", "Zebra", "Horse"),
                                                 count = c(1, 4, 2)))
bigDF <- createDataFrame(sqlContext, 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)