Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13760#discussion_r67799929
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -1347,6 +1347,65 @@ setMethod("gapply",
                 gapply(grouped, func, schema)
               })
     
    +#' gapplyCollect
    +#'
    +#' Groups the SparkDataFrame using the specified columns, applies the R 
function to each
    +#' group and collects the result back to R as data.frame.
    +#'
    +#' @param x A SparkDataFrame
    +#' @rdname gapplyCollect
    +#' @name gapplyCollect
    +#' @export
    +#' @examples
    +#'
    +#' \dontrun{
    +#' Computes the arithmetic mean of the second column by grouping
    +#' on the first and third columns. Output the grouping values and the 
average.
    +#'
    +#' result <- gapplyCollect(
    +#'   df,
    +#'   list("a", "c"),
    +#'   function(key, x) {
    +#'     y <- data.frame(key, mean(x$b), stringsAsFactors = FALSE)
    +#'     colnames(y) <- c("key_a", "key_c", "mean_b")
    +#'     y
    +#'   })
    +#'
    +#' Result
    +#' ------
    +#' key_a key_c mean_b
    +#' 3 3 3.0
    +#' 1 1 1.5
    +#'
    +#' Fits linear models on iris dataset by grouping on the 'Species' column 
and
    +#' using 'Sepal_Length' as a target variable, 'Sepal_Width', 'Petal_Length'
    +#' and 'Petal_Width' as training features.
    +#'
    +#' df <- createDataFrame (iris)
    +#' result <- gapplyCollect(
    +#'   df,
    +#'   list(df$"Species"),
    --- End diff --
    
    no need for a scalar to be a list. just df$"Species" is OK.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to