Suppose x is a real number, or a vector. i is valued-False. Then x[i] will return numeric(0). I would like to treat this as a real number 0, or integer 0, which are both fit for
You can use max/min with 0 to get 0 as output when input is numeric(0).
max
min
numeric(0)
x <- 1:10 max(x[FALSE], 0) #[1] 0 min(x[FALSE], 0) #[1] 0