rownamesToCol {FastUtils}R Documentation

Convert Row Names to a Column

Description

This function converts the row names of a data frame to a specified column. Note that if the specified column already exists, it is overwritten.

Usage

rownamesToCol(df, colname = "rownames")

Arguments

df

A data frame.

colname

A character string specifying the name of the new column to contain the row names. Defaults to "rownames".

Value

A data frame with the row names converted to a column.

Examples

# Convert row names to a column named 'ID'
df <- data.frame(Value = c(10, 20, 30))
rownames(df) <- c("A", "B", "C")
rownamesToCol(df, "ID")

[Package FastUtils version 0.1.1 Index]