Replace all values lower than threshold in R

r

Solution

`pmax` is a good candidate for this

  > pmax(x, 1)
    [1] 1 1 1 2 3

Problem

I have a vector ``` x <- c(-1, 0, 1, 2, 3) ``` I want all values less than 1 to be replaced by 1. How? Is there a no-loop solution?

Original source

Related problems