Last active
August 29, 2015 14:18
-
-
Save johnbaums/dd7b6b5ae37bf73faae3 to your computer and use it in GitHub Desktop.
Split vector x into groups with a specified number n of elements per group. If length(x) %% n is not 0, the final group will have fewer than n elements.
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
split_max_groupsize <- function(x, n) split(x, gl(ceiling(length(x)/n), n, length(x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment