Output it to a normal .csv
file but (if you're on a Linux-based or OSX system) use the split
command to divide it into multiple chunks. For example:
# In R:
write.table(dat, "inputs.csv")
# From the command line:
split -l$(echo $(wc -l inputs.csv | sed 's/\([0-9]\) .*/\1/g' | tr -d ' ') / 6 + 1| bc) inputs.csv inputs
The latter will create six .csv
files. The part in the middle is purely optional and calculates the number of lines that we should use per file if we want to split it into six pieces. If you know this number, say X, you can replace the above with split -lX inputs.csv inputs
.
Finally, if you wish to still do it in R, you can
six_groups <- split(tmp <- seq_len(nrow(dat)), floor(5.5 * rank(tmp) / length(tmp)))
for (group in seq_along(six_groups))
write.csv(dat[six_groups[[i]], ], paste0("Input", i, ".csv"))