withField: withField

Description Usage Arguments Note Examples

Description

Adds/replaces field in a struct Column by name.

Usage

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
df <- withColumn(
  createDataFrame(iris),
  "sepal",
   struct(column("Sepal_Width"), column("Sepal_Length"))
)

head(select(
  df,
  withField(df$sepal, "product", df$Sepal_Length * df$Sepal_Width)
))

## End(Not run)

SparkR documentation built on June 3, 2021, 5:05 p.m.