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
)A matrix/data_frame/tibble for transposing.
The column to transpose by. Default: The first column.
A name for the numeric data that will be transposed.
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
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
A transposed data table as a tibble.
Transposing can help with preforming operations on the rows of your tibbles.
select_all, select,
reexports, sym,
one_of
gather, unite, spread, separate
Other Data Manipulators:
convert_proportions(),
metacoder_comp_func_1(),
transformer(),
vlookup()
if (FALSE) { # \dontrun{
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")
}
} # }