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 so
Another option would be replace:
replace
x <- c(-1, 0, 1, 2, 3) replace(x, x < 1,1) # [1] 1 1 1 2 3