# NOT RUN {
vals <- rnorm(100,mean=5,sd=2)
pick <- which.closest(5.0,vals,index=TRUE) #closest to 5?
pick # the index of the closest
vals[pick] # its value
which.closest(5.0,vals,index=FALSE) # straight to the value
# }
Run the code above in your browser using DataLab