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
Run the code above in your browser using DataLab