Displaying 1 result from an estimated 1 matches for "int2bin".
2011 Dec 01
2
How to speed up int2bin conversion?
...converted this number to an 8 digit binary flag to get access to the
stored quality code (e.g. in2bin(165,8) = 1 0 1 0 0 1 0 1).
Unfortunately, I did not manage to find a package providing a fast
function to do so. I need to run this on millions of pixels and thus
wrote the following function.
int2bin <- function(x,ndigits){
base <- array(NA, dim=c(length(x), ndigits))
for(q in 1:ndigits){
base[, ndigits-q+1] <- (x %% 2)
x <- (x %/% 2)
}
bin<- apply(base,1,paste,collapse="")
return(bin)
}
Since it is still slow, I have to...