I have an array vals that contains values between 0 and 1 and I also have defined a threshold, th
vals <- c(0.0374250747263432, 0.00394217809662223, 0.0719008445739746,
0.0930692106485367, 0.0615200139582157)
th <- 0.5
How can I create a second vector vals_bnry whose elements are values of 0 or 1 based on the size of the corresponding elements in the vals vector?
Example:
if vals[1] > 0.5 -> vals_bnry[1] = 1
Is there a way to avoid the for loop?