A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://spark.apache.org/docs/latest/api/R/reference/unpivot.html below:

Unpivot a DataFrame from wide format to long format. — unpivot • SparkR

This is the reverse to groupBy(...).pivot(...).agg(...), except for the aggregation, which cannot be reversed.

Usage
unpivot(x, ids, values, variableColumnName, valueColumnName)

# S4 method for class 'SparkDataFrame,ANY,ANY,character,character'
unpivot(x, ids, values, variableColumnName, valueColumnName)

# S4 method for class 'SparkDataFrame,ANY,ANY,character,character'
melt(x, ids, values, variableColumnName, valueColumnName)
Arguments
x

a SparkDataFrame.

ids

a character vector or a list of columns

values

a character vector, a list of columns or NULL. If not NULL must not be empty. If NULL, uses all columns that are not set as ids.

variableColumnName

character Name of the variable column.

valueColumnName

character Name of the value column.

Note

unpivot since 3.4.0

melt since 3.4.0

See also

Other SparkDataFrame functions: SparkDataFrame-class, agg(), alias(), arrange(), as.data.frame(), attach,SparkDataFrame-method, broadcast(), cache(), checkpoint(), coalesce(), collect(), colnames(), coltypes(), createOrReplaceTempView(), crossJoin(), cube(), dapplyCollect(), dapply(), describe(), dim(), distinct(), dropDuplicates(), dropna(), drop(), dtypes(), exceptAll(), except(), explain(), filter(), first(), gapplyCollect(), gapply(), getNumPartitions(), group_by(), head(), hint(), histogram(), insertInto(), intersectAll(), intersect(), isLocal(), isStreaming(), join(), limit(), localCheckpoint(), merge(), mutate(), ncol(), nrow(), persist(), printSchema(), randomSplit(), rbind(), rename(), repartitionByRange(), repartition(), rollup(), sample(), saveAsTable(), schema(), selectExpr(), select(), showDF(), show(), storageLevel(), str(), subset(), summary(), take(), toJSON(), unionAll(), unionByName(), union(), unpersist(), withColumn(), withWatermark(), with(), write.df(), write.jdbc(), write.json(), write.orc(), write.parquet(), write.stream(), write.text()

Examples
if (FALSE) { # \dontrun{
df <- createDataFrame(data.frame(
  id = 1:3, x = c(1, 3, 5), y = c(2, 4, 6), z = c(-1, 0, 1)
))

head(unpivot(df, "id", c("x", "y"), "var", "val"))

head(unpivot(df, "id", NULL, "var", "val"))
} # }

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4