takeΒΆ

take returns the first NUM rows of a DataFrame as a local R data frame.

Syntax:

  • take(DataFrame, num)

Parameters:

  • DataFrame: Any SparkR DataFrame
  • num: Integer

Output:

  • local R DataFrame
require(SparkR)

# Create SparkR DataFrame
df <- createDataFrame(mtcars)
head(df)
# Convert first 3 rows into local R data frame
small_df <- take(df ,3)
small_df
# result of small_df is a local R data frame
str(small_df)