firstΒΆ

first returns the first row of a SparkDataFrame or the first value of a column.

Syntax:

  • first(SparkDataFrame)
  • first(SparkDataFrame$column)

Parameters:

  • SparkDataFrame: Any SparkDataFrame
  • column: Column in SparkDataFrame

Output:

  • SparkDataFrame or Column Object
require(SparkR)

# Create SparkDataFrame using the faithful dataset from R
df <- createDataFrame(faithful)

# Displays the content of the SparkDataFrame to stdout
head(df)
# Return first row of df
first(df)
# Return first value of column df$waiting
collect(select(df, first(df$waiting)))