Skip to content

Commit a8cfad3

Browse files
committed
Also mention replace_when()
After reading #5711 and #6511
1 parent 72fac75 commit a8cfad3

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

R/coalesce.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
#'
2424
#' - [na_if()] to replace a specified value with `NA`.
2525
#'
26-
#' - [replace_values()] for making arbitrary replacements.
26+
#' - [replace_values()] for making arbitrary replacements by value.
27+
#'
28+
#' - [replace_when()] for making arbitrary replacements using logical
29+
#' conditions.
2730
#'
2831
#' @export
2932
#' @examples

R/na-if.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
#'
2121
#' - [coalesce()] to replace `NA`s with the first non-missing value.
2222
#'
23-
#' - [replace_values()] for making arbitrary replacements.
23+
#' - [replace_values()] for making arbitrary replacements by value.
24+
#'
25+
#' - [replace_when()] for making arbitrary replacements using logical
26+
#' conditions.
2427
#'
2528
#' @export
2629
#' @examples
@@ -45,8 +48,11 @@
4548
#' replace_values(x, c(0, -1, -99) ~ NA)
4649
#' na_if(na_if(na_if(x, 0), -1), -99)
4750
#'
48-
#' # If you'd like to replace `NA` with some other value, again use
49-
#' # `replace_values()`
51+
#' # If you'd like to replace values that match a logical condition with `NA`,
52+
#' # use `replace_when()`
53+
#' replace_when(x, x < 0 ~ NA)
54+
#'
55+
#' # If you'd like to replace `NA` with some other value, use `replace_values()`
5056
#' x <- c(NA, 5, 2, NA, 0, 3)
5157
#' replace_values(x, NA ~ 0)
5258
#'

man/coalesce.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/na_if.Rd

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)