first

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

Syntax:

  • first(DataFrame)
  • first(DataFrame$column)

Parameters:

  • DataFrame: Any SparkR DataFrame
  • column: Column in DataFrame

Output:

  • SparkR DataFrame or Column Object
# Create SparkR DataFrame using the faithful dataset from R
df <- createDataFrame(sqlContext, faithful)

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