I have the question similar to What's the fastest method to return the position of the least significant bit set in an integer in Python 3? , finding the first set bit in a binary number , and Position of least significant bit that is set for R. I need to find the position of the least significant set bit in an integer in R. The solution proposed by Spätzle is the following:
unlist(lapply(x, function(z) min(which(as.integer(intToBits(z)) == 1))-1))
Are there more efficient ways to do it?