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

    https://github.com/apache/spark/pull/6183#discussion_r30445786
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -1431,3 +1431,119 @@ setMethod("describe",
                 sdf <- callJMethod(x@sdf, "describe", listToSeq(colList))
                 dataFrame(sdf)
               })
    +
    +#' dropna
    +#'
    +#' Returns a new DataFrame omitting rows with null values.
    +#'
    +#' @param x A SparkSQL DataFrame.
    +#' @param how "any" or "all".
    +#'            if "any", drop a row if it contains any nulls.
    +#'            if "all", drop a row only if all its values are null.
    +#'            if minNonNulls is specified, how is ignored.
    +#' @param minNonNulls If specified, drop rows that have less than
    +#'                    minNonNulls non-null values.
    +#'                    This overwrites the how parameter.
    +#' @param cols Optional list of column names to consider.
    +#' @return A DataFrame
    +#' 
    +#' @rdname nafunctions
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' sc <- sparkR.init()
    +#' sqlCtx <- sparkRSQL.init(sc)
    +#' path <- "path/to/file.json"
    +#' df <- jsonFile(sqlCtx, path)
    +#' dropna(df)
    +#' }
    +setMethod("dropna",
    +          signature(x = "DataFrame"),
    +          function(x, how = c("any", "all"), minNonNulls = NULL, cols = 
NULL) {
    +            how <- match.arg(how)
    +            if (is.null(cols)) {
    +              cols <- columns(x)
    +            }
    +            if (is.null(minNonNulls)) {
    +              minNonNulls <- if (how == "any") { length(cols) } else { 1 }
    +            }
    +            
    +            naFunctions <- callJMethod(x@sdf, "na")
    +            sdf <- callJMethod(naFunctions, "drop",
    +                               as.integer(minNonNulls), 
listToSeq(as.list(cols)))
    +            dataFrame(sdf)
    +          })
    +
    +#' fillna
    +#'
    +#' Replace null values.
    +#'
    +#' @param x A SparkSQL DataFrame.
    +#' @param value Value to replace null values with.
    +#'              Should be an integer, numeric, character or named list.
    +#'              If the value is a named list, then cols is ignored and
    +#'              value must be a mapping from column name (character) to 
    +#'              replacement value. The replacement value must be an
    +#'              integer, numeric or character.
    +#' @param cols optional list of column names to consider.
    +#'             Columns specified in cols that do not have matching data
    +#'             type are ignored. For example, if value is a character, and 
    +#'             subset contains a non-character column, then the 
non-character
    +#'             column is simply ignored.
    +#' @return A DataFrame
    +#' 
    +#' @rdname nafunctions
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' sc <- sparkR.init()
    +#' sqlCtx <- sparkRSQL.init(sc)
    +#' path <- "path/to/file.json"
    +#' df <- jsonFile(sqlCtx, path)
    --- End diff --
    
    Could you also add an example here how how the named list usage looks ?


---
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