withColumnRenamed,DataFrame,character,character-method {SparkR}R Documentation

WithColumnRenamed

Description

Rename an existing column in a DataFrame.

Rename an existing column in a DataFrame.

Usage

## S4 method for signature 'DataFrame,character,character'
withColumnRenamed(x, existingCol,
  newCol)

## S4 method for signature 'DataFrame'
rename(x, ...)

rename(x, ...)

withColumnRenamed(x, existingCol, newCol)

Arguments

x

A DataFrame

existingCol

The name of the column you want to change.

newCol

The new column name.

x

A DataFrame

newCol

A named pair of the form new_column_name = existing_column

Value

A DataFrame with the column name changed.

A DataFrame with the column name changed.

Examples

## Not run: 
##D sc <- sparkR.init()
##D sqlContext <- sparkRSQL.init(sc)
##D path <- "path/to/file.json"
##D df <- jsonFile(sqlContext, path)
##D newDF <- withColumnRenamed(df, "col1", "newCol1")
## End(Not run)
## Not run: 
##D sc <- sparkR.init()
##D sqlContext <- sparkRSQL.init(sc)
##D path <- "path/to/file.json"
##D df <- jsonFile(sqlContext, path)
##D newDF <- rename(df, col1 = df$newCol1)
## End(Not run)

[Package SparkR version 1.4.1 Index]