transposer: Transposing Tidy Data

Description Usage Arguments Details Value See Also Examples

View source: R/utils.R

Description

This function transposes tables containing numeric and categorical data using the tidyr package.

Usage

1
2
transposer(.data, ids = NULL, header_name, preserved_categories = TRUE,
  separated_categories = NULL)

Arguments

.data

A matrix/data_frame/tibble for transposing.

ids

The column to transpose by. Default: The first column.

header_name

A name for the numeric data that will be transposed.

preserved_categories

A logical denoting weather categorical data should be conserved. A value of FALSE will cause all categorical data except the ids to be dropped. A value of TRUE will cause the categorical data to preserved by tidyr::uniteing these columns. Default: TRUE

separated_categories

A vector containing ordered column names to use in a previously transposed and categorically preserved table. Retransposing with this set should yield an exact replicate of the original data. Default: NULL

Details

Transposing can help with preforming operations on the rows of your tibbles.

Value

A transposed data table as a tibble.

See Also

is_tibble

select_all, select, reexports, sym, one_of

gather, unite, spread, separate

str_detect, str_count

Other Data Manipulators: convert_proportions, metacoder_comp_func_1, transformer, vlookup

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
if(interactive()){
# This example uses data that are no longer available in the MicrobiomeR package,
# however, they can be easily generated with \code{\link{MicrobiomeR}{as_basic_format}}.
 library(MicrobiomeR)
 basic_silva <- as_MicrobiomeR_format(MicrobiomeR::raw_silva_2, "basic_format")
 data <- basic_silva$data$taxa_abundance
 trans_data <- data %>%
   transposer(ids = "taxon_id", header_name = "samples")
 retrans_data <- trans_data %>%
   transposer(ids="samples", header_name="taxon_id")
 }

## End(Not run)

vallenderlab/MicrobiomeR documentation built on Aug. 30, 2019, 11:24 p.m.