dropFields {SparkR} | R Documentation |
Drops fields in a struct Column
by name.
dropFields(x, ...)
## S4 method for signature 'Column'
dropFields(x, ...)
x |
a Column |
... |
names of the fields to be dropped. |
dropFields since 3.1.0
## Not run:
##D df <- select(
##D createDataFrame(iris),
##D alias(
##D struct(
##D column("Sepal_Width"), column("Sepal_Length"),
##D alias(
##D struct(
##D column("Petal_Width"), column("Petal_Length"),
##D alias(
##D column("Petal_Width") * column("Petal_Length"),
##D "Petal_Product"
##D )
##D ),
##D "Petal"
##D )
##D ),
##D "dimensions"
##D )
##D )
##D head(withColumn(df, "dimensions", dropFields(df$dimensions, "Petal")))
##D
##D head(
##D withColumn(
##D df, "dimensions",
##D dropFields(df$dimensions, "Sepal_Width", "Sepal_Length")
##D )
##D )
##D
##D # This method supports dropping multiple nested fields directly e.g.
##D head(
##D withColumn(
##D df, "dimensions",
##D dropFields(df$dimensions, "Petal.Petal_Width", "Petal.Petal_Length")
##D )
##D )
##D
##D # However, if you are going to add/replace multiple nested fields,
##D # it is preferred to extract out the nested struct before
##D # adding/replacing multiple fields e.g.
##D head(
##D withColumn(
##D df, "dimensions",
##D withField(
##D column("dimensions"),
##D "Petal",
##D dropFields(column("dimensions.Petal"), "Petal_Width", "Petal_Length")
##D )
##D )
##D )
## End(Not run)