How can I create a vector S, with
S[i] = 1, if Tv[i] is the closest number to an integer in I<- 6:10
S[i] = 0 else
Tv <- c(5.946, 5.978,
6.01, 6.043, 6.075, 6.109, 6.14, 6.173, 6.205, 6.239,
6.273, 6.309, 6.344, 6.379, 6.415, 6.45, 6.486, 6.521, 6.556,
6.59, 6.627, 6.665, 6.703, 6.741, 6.778, 6.816, 6.852, 6.891,
6.928, 6.967, 7.005, 7.045, 7.084, 7.124, 7.161, 7.202, 7.24)
S <- getS(Tv)
> dput(S)
c(0, 0, 1, 0, 0 ....)
Final goal is to have a list like a ruler with 1 where the value is closest to the next integer value.
Here is one way: