splitinput Splits input based on keepcol specified, yielding csv files each with at least the mininum number of rows that are written and saved separately (except for the last split file written, which may be smaller). Allows splitting input data while ensuring all records for each individual subject will stay together in one file. Pads split filenames with zeros out to five digits for consistency, assuming < 100,000 file count result.

  fname = deparse(substitute(df)),
  fdir = NA,
  min_nrow = 10000,
  keepcol = "subjid"



data frame to split


new name for each of the split files to start with


directory to put each of the split files (use "." for working directory). Must be changed from default (NA), which will trigger error.


minimum number of rows for each split file (default 10000)


the column name (default "subjid") to use to keep records with the same values together in the same single split file


the count number referring to the last split file written


# \donttest{
# Run on given data
df <- as.data.frame(syngrowth)

# Run with all defaults (specifying directory)
splitinput(df, fdir = tempdir())
#> [1] 7

# Specifying the name, directory and minimum row size
splitinput(df, fname = "syngrowth", fdir = tempdir(), min_nrow = 5000)
#> [1] 15

# Specifying a different subject ID column
colnames(df)[colnames(df) == "subjid"] <- "sub_id"
splitinput(df, fdir = tempdir(), keepcol = "sub_id")
#> [1] 7
# }