Skip to content

Instantly share code, notes, and snippets.

@Shians
Created February 24, 2020 22:39
Show Gist options
  • Select an option

  • Save Shians/8a88976b77958c5f3914ad432122a218 to your computer and use it in GitHub Desktop.

Select an option

Save Shians/8a88976b77958c5f3914ad432122a218 to your computer and use it in GitHub Desktop.
Function to split a data.frame in to n chunks
split_n_chunks <- function(x, n) {
stopifnot(is(x, "data.frame"))
f <- ceiling(seq_len(nrow(x)) / (nrow(x) / n))
split(x, f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment