This is an R function written to split a dataset into particular sized sets, then write them as a CSV. Often, our office is need a quick way to split files for uploading purposes, since our HMIS software doesn't handle large uploads well.
For example:
splitDataAndWriteFiles(df, 500, "My_Data")
Will produce X number of files named "My_data_X.csv"
options(java.parameters = "-Xmx14336m") ## memory set to 14 GB
library("XLConnect")
# Function to split files.
splitDataAndWriteFiles <- function(df, chunkSize, nameOfFiles) {
success <- FALSE
count <- 0
while (!success) {
# If you want 20 samples, put any range of 20 values within the range of number ...