last

last returns the last value in a column.

Syntax:

  • last(DataFrame$column)

Parameters:

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

Output:

  • 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 value of column df$waiting
collect(select(df, last(df$waiting)))