column_to_rownames {textshape}R Documentation

Add a Column as Rownames

Description

Takes an existing column and uses it as rownames instead. This is useful when turning a data.frame into a matrix. Inspired by the tibble package's column_to_row which is now deprecated if done on a tibble object. By coercing to a data.frame this problem is avoided.

Usage

column_to_rownames(x, loc = 1)

Arguments

x

An object that can be coerced to a data.frame.

loc

The column location as either an integer or string index location. Must be unique row names.

Value

Returns a data.frame with the specified column moved to rownames.

Examples

state_dat <- data.frame(state.name, state.area, state.center, state.division)
column_to_rownames(state_dat)
column_to_rownames(state_dat, 'state.name')

[Package textshape version 1.7.5 Index]