withField {SparkR}R Documentation

withField

Description

Adds/replaces field in a struct Column by name.

Usage

withField(x, fieldName, col)

## S4 method for signature 'Column,character,Column'
withField(x, fieldName, col)

Arguments

x

a Column

fieldName

a character

col

a Column expression

Note

withField since 3.1.0

Examples



## Not run: 
##D df <- withColumn(
##D   createDataFrame(iris),
##D   "sepal",
##D    struct(column("Sepal_Width"), column("Sepal_Length"))
##D )
##D 
##D head(select(
##D   df,
##D   withField(df$sepal, "product", df$Sepal_Length * df$Sepal_Width)
##D ))
## End(Not run)




[Package SparkR version 3.2.4 Index]