Skip to contents

Rename an existing column in a SparkDataFrame.

Usage

rename(x, ...)

withColumnRenamed(x, existingCol, newCol)

# S4 method for class 'SparkDataFrame,character,character'
withColumnRenamed(x, existingCol, newCol)

# S4 method for class 'SparkDataFrame'
rename(x, ...)

Arguments

x

A SparkDataFrame

...

A named pair of the form new_column_name = existing_column

existingCol

The name of the column you want to change.

newCol

The new column name.

Value

A SparkDataFrame with the column name changed.

Note

withColumnRenamed since 1.4.0

rename since 1.4.0

Examples

if (FALSE) { # \dontrun{
sparkR.session()
path <- "path/to/file.json"
df <- read.json(path)
newDF <- withColumnRenamed(df, "col1", "newCol1")
} # }
if (FALSE) { # \dontrun{
sparkR.session()
path <- "path/to/file.json"
df <- read.json(path)
newDF <- rename(df, col1 = df$newCol1)
} # }