ncol

ncol returns the number of columns in a DataFrame

Syntax:

  • ncol(df)

Parameters:

  • df: Any SparkR DataFrame

Output:

  • List
# Create SparkR DataFrame
df <- createDataFrame(sqlContext, mtcars)
head(df)
# View number of columns in df
ncol(df)