dt.combination: Combines 2 columns from a datatable into a 1 column...

dt.combinationR Documentation

Combines 2 columns from a datatable into a 1 column data.table.

Description

Combines 2 columns from a datatable into a 1 column data.table.

Usage

dt.combination(DT, cols, mrg.col, keep.colname = NULL, check.len = TRUE)

Arguments

DT

A data.table.

cols

A character vector of length 2 matching columns names of DT.

mrg.col

A character to be used to name the resulting combined column.

keep.colname

An integer equals to 1, or 2, or NULL. If equals to 1, the resulting combined column will be named after the first column in 'cols'. If equals to 2, the resulting combined column will be named after the second column in 'cols'. If NULL, keep.colname is not used for the naming of the resulting combined column (Default: keep.colname = NULL).

check.len

A logical specifying whether the length of each values obtained in the resulting combined column should be checked (Default : check.len = TRUE) or not (check.len = FALSE). If check.len = TRUE and the length of any value is superior to 1, an error message will be returned. It can be useful sometimes to set check.len to FALSE, especially if you know that some values in the columns you want to combine contain whitespaces. In such case, it is advised to set check.len = TRUE.

Value

A data.table with 1 column resulting from the merging of the partially duplicated columns of the input.

Author(s)

Yoann Pageaud.


YoannPa/DTrsiv documentation built on Nov. 28, 2022, 5:44 p.m.