Skip to contents

This function converts a data.table to a data.frame, optionally setting row names from a specified column.

Usage

to.data.frame(x, id.col = NULL, drop.id.col = TRUE)

Arguments

x

A data.table object to convert.

id.col

The name of the column to use as row names. If NULL, no row names are set. Default is NULL.

drop.id.col

Logical. If TRUE and id.col is specified, the id column is removed after setting row names. Default is TRUE.

Value

A data.frame converted from the input data.table.

Examples

library(data.table)
dt <- data.table(id = letters[1:3], value = 1:3)
to.data.frame(dt, id.col = "id")
#>   value
#> a     1
#> b     2
#> c     3
# Returns a data.frame with row names set to "a", "b", "c" and "id" column removed