R/replace_with.R

Defines functions replace_with

replace_with <- function(x, i, val, name) {
  check_length_val(length(val), length(x), name)

  i[is.na(i)] <- FALSE

  if (length(val) == 1L) {
    x[i] <- val
  } else {
    x[i] <- val[i]
  }

  x
}

Try the incase package in your browser

Any scripts or data that you put into this service are public.

incase documentation built on Jan. 16, 2021, 5:21 p.m.