sortByRowIndexDT: Order the rows of a data.table object by index

Description Usage Arguments Value Examples

View source: R/funcDT.R

Description

Order the rows of a data.table object by index

Usage

1
sortByRowIndexDT(inputDT, rowIndices)

Arguments

inputDT

data.table object containing the data of interest. This is an obligatory argument, without default value.

rowIndices

Integer vector that contains the row indices according to which the 'inputDT' object should be ordered. This is an obligatory argument, without default value.

Value

The 'inputDT' data.table object, ordered according to the 'rowIndices' argument. This function assumes that the length of the 'rowIndices' argument is correspond to the number of rows of the 'inputDT' argument. If the length of the 'rowIndices' argument is smaller than the number of rows of the 'inputDT' argument, the values of the 'rowIndices' argument are recycled until the as many indices as number of rows of the 'inputDT' argument is obtained.

Examples

1
2
3
4
5
6
library(data.table)
inputDT <- as.data.table(data.frame(x = 10:1, y = LETTERS[1:10]))
asFactorDT(inputDT, c('y'))
inputDT
sortByRowIndexDT(inputDT, 10:1)
inputDT

R2DT documentation built on March 26, 2020, 5:59 p.m.

Related to sortByRowIndexDT in R2DT...