transpose: Easily transpose tibble and data.frame and data.table

ttR Documentation

Easily transpose tibble and data.frame and data.table

Description

Function from data.table.

Usage

tt(x, colnames_to_columm, column_to_colnames, ...)

## Default S3 method:
tt(x, colnames_to_columm, column_to_colnames, ...)

## S3 method for class 'tbl_df'
tt(x, colnames_to_columm = "col_id", column_to_colnames = 1, ...)

## S3 method for class 'data.table'
tt(x, colnames_to_columm = "col_id", column_to_colnames = 1, ...)

Arguments

x

an tibble or data.table

colnames_to_columm

The name of the first column in the result containing the colnames of the input.

column_to_colnames

The name or number of a column in the input to use as colnames of the output.

...

Others params from data.table::transpose().

Value

a transpose tibble

a transpose data.table

Examples

tibble::as_tibble(mtcars, rownames = "row_id") %>% tt()
tibble::as_tibble(mtcars, rownames = "row_id") %>%
    tt() %>%
    tt()
tibble::as_tibble(mtcars, rownames = "row_id") %>%
    data.table::as.data.table() %>%
    tt()


yanpd01/yyeasy documentation built on Dec. 1, 2022, 10:58 p.m.