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

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

Value

A transposed data table as a tibble.

Details

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

See also

Examples

# 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")
 }
# }