# alias¶

alias sets a new name for a column in a SparkDataFrame. Typically used together with column operations.

If you need the entire SparkDataFrame with only a certain column renamed, see withColumnRenamed.

Syntax:

• alias(df$colName, “newColName”) Parameters: • df: Any SparkDataFrame • colName: Column in SparkDataFrame • newColName: String, new column name Output: • Column Object require(SparkR) # Create SparkDataFrame df <- createDataFrame(mtcars) head(df)  # Select mpg column in df with new column name "milesPerGallon" head(select(df, alias(df$mpg, "milesPerGallon")))

# alias() is usually used with column operations