KH.depart: Separate data set into multiple output files for each...

Description Usage Arguments Details Examples

View source: R/Helper.R

Description

Separate data set into multiple output files for each departing item

Usage

1
2
KH.depart(DT, departingColumn, outputDir, writeWholeToo = TRUE,
  output.format = "csv", ...)

Arguments

DT

data.table. Data object containing multiple rows and columns.

departingColumn

string A single value which name of one of the columns in the data set. This will be used to separate data.

outputDir

string. Path to a directory to save the output. If it does not exist, it will be created. Data inside the directory will be overwritten without notice.

writeWholeToo

logical. If TRUE write whole data set into a file alongside the separated files. Default is TRUE.

output.format

string. Format of the output files. Default is CSV. Possible values are csv and xlsx

...

Dots. This is usually ..., although other types are accepted.

Details

After separating data based on the given column, each part is written to a separate file in the given directory. If the directory does not exist, it will be created. If the directory exists and contains data, they will be overwritten without notice.

Examples

1
2
3
4
5
6
7
8
{
input_file <- system.file("extdata", "input_file.csv", package = "KHanSUtils")
DT <- KH.loadCSV(input_file)
KH.depart(DT, 'origin', '/tmp/test-csv')
#[1] TRUE
KH.depart(DT, 'origin', '/tmp/test-xlsx', output.format = 'xlsx')
#[1] TRUE
}

ks465/r-utils documentation built on May 23, 2019, 5:07 p.m.