dt_keeprownames: Create data.table from data.frame with row names

View source: R/dt_keeprownames.R

dt_keeprownamesR Documentation

Create data.table from data.frame with row names

Description

This a wrapper function around data.table(df, keep.rownames=TRUE)

For more information about data.table and data.frame Google it.

Usage

dt_keeprownames(df, check.names=FALSE, key = NULL, stringsAsFactors = FALSE)

Arguments

df

a data.frame

check.names

same as in data.frame

key

character vector of one or more column names which is passed to setkey

stringsAsFactors

same as in data.table

Value

returns a data.table

Examples

dt_keeprownames(mtcars)

## Not run: 
dt_keeprownames(data.table(mtcars)) # this will throw an error because input is not a data.frame
df <- mtcars
rownames(df) <- NULL
dt_keeprownames(df)
# if data.frame has no row names, the returned data.table will create column rn
with row index numbers

## End(Not run)


kleu046/wr.data.table documentation built on April 25, 2022, 1:41 p.m.