format_table: Transform dataset to a standard table format

Description Usage Arguments Value Examples

View source: R/format_table.R

Description

Transforms a matrix, data frame or data table to an ordered data table with the key as the first column. The key column can be passed, selected by its column name or extracted from row names.

Usage

1
2
format_table(x, key_col = key(x), key_data = NULL, sort = TRUE,
  df = FALSE)

Arguments

x

A matrix, data frame or data table.

key_col

Character vector of one or more column names which is passed to setkey. If x has a key, it can be ommited.

key_data

A vector of length nrow(x) to be used as key. If the (first) column name in key_col is already a column of x, it will be substituted by key_data and the table reordered. Otherwise, and if key_data is missing, row.names(x) will be used instead.

sort

Wheter to sort by key_col. Defaults to TRUE.

df

Return a data frame instead of a data table. Defaults to FALSE.

Value

A data table (or data frame) based on x and ordered by key_col.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(geneData, geneCovariate, package='Biobase')
gData <- head(geneData, n=5)

gData
class(gData)

gData <- format_table(gData, 'Probeset')
gData
class(gData)
key(gData)

gData <- format_table(gData, key_data=row.names(geneData)[6:10], sort=FALSE)
gData
key(gData)

csbl-usp/collapseR documentation built on May 6, 2019, 8:32 p.m.