Created
February 11, 2014 12:45
-
-
Save jakosz/8934204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Groups indices of a list or vector into n (almost) equal chunks: | |
iTable <- | |
function (x, n) | |
{ | |
x = seq_along(x) | |
i = floor(seq(from = x[1], to = x[length(x)], length.out = n + | |
1)) | |
res = data.frame(from = i[1:(length(i) - 1)], to = i[2:length(i)]) | |
res$from[2:nrow(res)] = res$from[2:nrow(res)] + 1 | |
return(res) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment