dth_key: Setkey for multiple data.tables in one function

View source: R/dth_key.R

dth_keyR Documentation

Setkey for multiple data.tables in one function

Description

Setkey for multiple data.tables in one function

Usage

dth_key(...)

Arguments

...

Examples

# Make data.tables
require(data.table)
dt1 <- as.data.table(iris[,c(1,3,5)])
dt2 <- as.data.table(iris[,c(2,3,5)])
dt3 <- as.data.table(iris[,c(4,3,5)])

# they have not key set
sapply(list(dt1,dt2,dt3), key)

# First key set
dth_key(dt1, dt2, dt3, Species)
sapply(list(dt1,dt2,dt3), key)

# Key can change
dth_key(dt1, dt2, dt3, Petal.Length)
sapply(list(dt1,dt2,dt3), key)

# Key values can be a mix of quoted and non-quoted text
dth_key(dt1, dt2, dt3, Petal.Length, 'Species')
sapply(list(dt1,dt2,dt3), key)

# order doesn't matter
dt1 <- as.data.table(iris[,c(1,3,5)])
dt2 <- as.data.table(iris[,c(2,3,5)])
dt3 <- as.data.table(iris[,c(4,3,5)])
sapply(list(dt1,dt2,dt3), key)
dth_key(dt1,Petal.Length, dt3,'Species',dt2 )
sapply(list(dt1,dt2,dt3), key)



dbrookeUAB/dth documentation built on Oct. 6, 2022, 10:52 p.m.