Skip to content

Instantly share code, notes, and snippets.

@wahalulu
Created June 22, 2011 21:20
Show Gist options
  • Save wahalulu/1041245 to your computer and use it in GitHub Desktop.
Save wahalulu/1041245 to your computer and use it in GitHub Desktop.
Convert integers to IP dot addresses in R - separated
int2ip_sep <- function(int) {
val <- sprintf("%x", int)
pos <- matrix(c(seq(1,7,2), seq(2,8,2)), ncol = 2)
spl <- apply(pos, 1, function(x) {substr(val, x[1], x[2])})
as.numeric(sapply(spl, function(x) {sprintf("%d",
as.numeric(paste("0x",
x, sep="")))}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment