Github user mhnatiuk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13295#discussion_r65063712
  
    --- Diff: R/pkg/R/group.R ---
    @@ -126,6 +126,47 @@ methods <- c("avg", "max", "mean", "min", "sum")
     # These are not exposed on GroupedData: "kurtosis", "skewness", "stddev", 
"stddev_samp", "stddev_pop",
     # "variance", "var_samp", "var_pop"
     
    +#' Pivot
    +#' 
    +#' Pivot GroupedData column to expand unique values of this column into 
set of column named accordingly and perform
    +#' aggregation. Same purpose as dcast in reshape2 or pivot table in Excel
    +#' 
    +#' @param x: a GroupedData object
    +#' @param by: name of column to pivot data by
    +#' @param values: a unique list of values that will be translated to 
columns in the output SparkDataFrame. 
    +#' If not given it will be computed on the fly which will influence 
performance
    +#' @return GroupedData object
    +#' @rdname pivot
    +#' @export 
    +#' @examples 
    +#' \dontrun{
    +#' library(magrittr)
    +#' df <- data.frame(
    +#'     earnings = c(10000, 10000, 11000, 15000, 12000, 20000, 21000, 
22000),
    +#'     course = c("R", "Python", "R", "Python", "R", "Python", "R", 
"Python"),
    +#'     year = c(2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016)
    +#' )
    +#' SparkRdf <- createDataFrame(sqlContext, df)
    +#' values <- list("R", "Python")
    +#' sums <- groupBy(SparkRdf, "year") %>% 
    +#'     pivot("course", values) %>% 
    +#'     SparkR::summarize(sumOfEarnings = sum(SparkRdf$earnings) ) %>%
    +#'     collect()
    +#' }
    +
    +setMethod("pivot",
    +          signature(x = "GroupedData"),
    +          function(x, colname, values=NULL){
    --- End diff --
    
    OK, so I'll add a test to verify that list ain't empty, right? Or does the 
underlaying scala method accept empty lists?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to