Description Usage Arguments Value Examples
This method will take a sequence of column names (strings) and unpivots them into two columns, the "variable_name" and its values.
1 |
sc |
A |
data |
A |
id_variables |
list(string). Column(s) which are used as unique identifiers. |
value_variables |
list(string). Column(s) which are being unpivoted. |
variable_name |
c(string). The name of a new column, which holds all
the |
value_name |
c(string). The name of a new column, which holds all the
values of |
Returns a jobj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## Not run:
# Set up a spark connection
sc <- spark_connect(master = "local", version = "2.2.0")
# Extract some data
melt_data <- spark_read_json(
sc,
"melt_data",
path = system.file(
"data_raw/Melt.json",
package = "sparkts"
)
) %>%
spark_dataframe()
# Call the method
p <- sdf_melt(
sc = sc, data = melt_data, id_variables = c("identifier", "date"),
value_variables = c("two", "one", "three", "four"),
variable_name = "variable", value_name = "turnover"
)
#' # Return the data to R
p %>% dplyr::collect()
spark_disconnect(sc = sc)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.