Learn R Programming

tidyfst (version 1.8.1)

rn_col: Tools for working with row names

Description

The enhanced data.frame, including tibble and data.table, do not support row names. To link to some base r facilities, there should be functions to save information in row names. These functions are analogous to rownames_to_column and column_to_rownames in tibble.

Usage

rn_col(.data, var = "rowname")

col_rn(.data, var = "rowname")

Value

rn_col returns a data.table, col_rn returns a data frame.

Arguments

.data

A data.frame.

var

Name of column to use for rownames.

Examples

Run this code

 mtcars %>% rn_col()
 mtcars %>% rn_col("rn")

 mtcars %>% rn_col() -> new_mtcars

 new_mtcars %>% col_rn() -> old_mtcars
 old_mtcars
 setequal(mtcars,old_mtcars)

Run the code above in your browser using DataLab