| replace | R Documentation |
[<-Fast vector replacement, an alternative to [<-
replace_(x, where, with, in_place = FALSE, quiet = FALSE)
x |
A vector. |
where |
|
with |
Replacement values. These will be recycled against the
resulting |
in_place |
|
quiet |
Should warnings be suppressed when |
A vector whose values are
replaced with with at locations specified by where.
library(cheapr)
x <- set_round(seq_(-2, 2, by = 0.5))
x |>
replace_(1, with = 100) # Assign value 100 at location 1
# Base R casts to `x` and replacement to a common type
`[<-`(x, x== 0, "42")
# `assign_at` only casts replacement to type of x
x |>
replace_(x == 0, with = "42") # Assign value 42 where x == 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.