group_write splits a data frame according to (multiple) grouping variables, write out each part with file name indicating specific groups.

group_write(df, ..., dir = "")

Arguments

df

a data frame

...

grouping variables

dir

output directory. By default, the output files are stored under the current working directory

Value

group_write returns the input data frame invisibly.

Examples

library(ymisc)
group_write(iris, Species)
list.files(pattern = "\\.csv$")
#> [1] "iris-setosa.csv"     "iris-versicolor.csv" "iris-virginica.csv" 

# Currently, you need to convert `df` into a data frame outside this function
# before passing the argument.
# For example, `group_write(as.data.frame(Titanic), Sex, Age)` does not work