withColumnRenamed,DataFrame,character,character-method {SparkR} | R Documentation |
Rename an existing column in a DataFrame.
Rename an existing column in a DataFrame.
## S4 method for signature 'DataFrame,character,character' withColumnRenamed(x, existingCol, newCol) ## S4 method for signature 'DataFrame' rename(x, ...) rename(x, ...) withColumnRenamed(x, existingCol, newCol)
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 |
A DataFrame with the column name changed.
A DataFrame with the column name changed.
## 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)