textshape (version 1.7.5)

column_to_rownames: 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)

Value

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

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.

Examples

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

Run the code above in your browser using DataLab