chunk_data_frame: Chunk a data frame

chunk_data_frameR Documentation

Chunk a data frame

Description

Use chunk_by_id to split up a data set by the ID column; use chunk_by_row split a data set by rows.

Usage

chunk_by_id(data, nchunk, id_col = "ID", mark = NULL)

chunk_by_cols(data, nchunk, cols, mark = NULL)

chunk_by_row(data, nchunk, mark = NULL)

Arguments

data

A data frame.

nchunk

The number of chunks.

id_col

Character name specifying the column containing the ID for chunking.

mark

When populated as a character label, adds a column to the chunked data frames with that name and with value the integer group number.

cols

A character vector of columns to use for deriving ID to use for chunking.

Value

A list of data frames.

Examples

x <- expand.grid(ID = 1:10, B = rev(1:10))

chunk_by_id(x, nchunk = 3)

chunk_by_row(x, nchunk = 4)


mrgsim.parallel documentation built on March 18, 2022, 7:52 p.m.