id_across_datasets: ID across datasets

Description Usage Arguments Value Examples

View source: R/id_across_datasets.R

Description

Create an ID column in each of the data sets. The ID values will span across the data sets.

Usage

1
2
3
4
5
6
id_across_datasets(
  dt_list = NULL,
  id_col_name = "id",
  id_col_position = "first",
  silent = FALSE
)

Arguments

dt_list

a list of data.table objects

id_col_name

name of the column that will contain ID values

id_col_position

position of the newly created ID column. If id_col_position = "first", the new ID column will be placed as the first column in respective data sets. If id_col_position = "last", the new ID column will be placed as the last column in respective data sets.

silent

If silent = TRUE, a summary of starting and ending ID values in each data set will not be printed. If silent = FALSE, a summary of starting and ending ID values in each data set will be printed. (default = FALSE)

Value

the output will be a list of data.table objects.

Examples

1
2
3
4
5
6
7
8
# running the examples below requires importing the data.table package.
prep(data.table)
id_across_datasets(
dt_list = list(setDT(copy(mtcars)), setDT(copy(iris))))
id_across_datasets(
dt_list = list(setDT(copy(mtcars)), setDT(copy(iris)), setDT(copy(women))),
id_col_name = "newly_created_id_col",
id_col_position = "last")

kim documentation built on April 25, 2021, 1:06 a.m.