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

    https://github.com/apache/spark/pull/18422#discussion_r124719080
  
    --- Diff: R/pkg/R/functions.R ---
    @@ -2819,20 +2775,26 @@ setMethod("unix_timestamp", signature(x = "Column", 
format = "character"),
                 jc <- callJStatic("org.apache.spark.sql.functions", 
"unix_timestamp", x@jc, format)
                 column(jc)
               })
    -#' when
    -#'
    -#' Evaluates a list of conditions and returns one of multiple possible 
result expressions.
    +
    +#' @details
    +#' \code{when}: Evaluates a list of conditions and returns one of multiple 
possible result expressions.
     #' For unmatched expressions null is returned.
     #'
    +#' @rdname column_nonaggregate_functions
     #' @param condition the condition to test on. Must be a Column expression.
     #' @param value result expression.
    -#' @family non-aggregate functions
    -#' @rdname when
    -#' @name when
    -#' @aliases when,Column-method
    -#' @seealso \link{ifelse}
    +#' @aliases when when,Column-method
     #' @export
    -#' @examples \dontrun{when(df$age == 2, df$age + 1)}
    +#' @examples
    +#'
    +#' \dontrun{
    +#' tmp <- mutate(df, mpg_na = otherwise(when(df$mpg > 20, df$mpg), 
lit(NaN)),
    +#'                   mpg2 = ifelse(df$mpg > 20 & df$am > 0, 0, 1),
    +#'                   mpg3 = ifelse(df$mpg > 20, df$mpg, 20.0))
    +#' head(tmp)
    +#' tmp <- mutate(tmp, ind_na1 = is.nan(tmp$mpg_na), ind_na2 = 
isnan(tmp$mpg_na))
    +#' head(select(tmp, coalesce(tmp$mpg_na, tmp$mpg)))
    +#' head(select(tmp, nanvl(tmp$mpg_na, tmp$hp)))}
    --- End diff --
    
    @felixcheung  Examples for `coalesce` and `nanvl` are here.


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