split_save: Export a single dataset into multiple files by group

View source: R/split_save.R

split_saveR Documentation

Export a single dataset into multiple files by group

Description

'split_save' breaks a dataset by the groups provided and then exports those individual frames as separate csv files. This process can be useful when working with data across multiple partners and then creating datasets to be sent to each of them with their own data.

Usage

split_save(df, group_var, folderpath, filename_stub, include_date = FALSE)

Arguments

df

dataframe to split

group_var

grouping variable to split the dataset by, eg operatingunit, funding_agency

folderpath

directory where you want to store the files

filename_stub

generic stub for naming all the files

include_date

include date after filenamestub? default = FALSE, eg "20180913"

Examples

## Not run: 
#create country specific files for TX_NEW
 df_mer %>%
  filter(indicator == "TX_NEW",
         standardizeddisaggregate == "Total Numerator") %>%
  split_save(operatingunit, "~/CountryFiles", "FY18Q3_TX")

## End(Not run)

USAID-OHA-SI/gophr documentation built on Nov. 14, 2024, 8:30 p.m.