Skip to contents

This function splits a data frame by the unique values in a specified column and saves each subset as a CSV file. The CSV files will be named based on the unique values in the specified column.

Usage

split_and_save_csv(df, split_col, output_dir = ".", sep = ",")

Arguments

df

A data frame to be split.

split_col

The name of the column to split the data frame by (as a string).

output_dir

The directory where the CSV files will be saved. Default is the current working directory.

sep

The separator used in the CSV files. Default is a comma (,).

Value

No return value. CSV files are saved to disk.

Examples

if (FALSE) { # \dontrun{
# Assuming df has a column named "datasetName"
split_and_save_csv(df, split_col = "datasetName", output_dir = "output/")
} # }