dtypes

dtypes returns a list of all column names of a DataFrame and their respective data types.

Syntax:

  • dtypes(DataFrame)

Parameters:

  • DataFrame: Any SparkR DataFrame

Output:

  • List
# Create SparkR DataFrame using the faithful dataset from R
df <- createDataFrame(sqlContext, iris)

# Displays the content of the DataFrame to stdout
head(df)
# View column names with their respective data types
dtypes(df)