cast: Cast data from long to wide format

castR Documentation

Cast data from long to wide format

Description

Pivot column data from long format to wide format.

Usage

cast(object, ...)

## S4 method for signature 'DFrame'
cast(object, colnames = "colname", values = "value")

Arguments

object

Object.

colnames

character(1). Name of the column that contains the column name values in long format. Must define an unordered factor column.

values

character(1). Name of the column that contains the values in long format. Must define an atomic column that is not factor.

...

Additional arguments.

Value

DataFrame.

Note

Updated 2023-08-23.

See Also

  • https://seananderson.ca/2013/10/19/reshape/

  • reshape2::dcast (deprecated).

  • tidyr::pivot_wider.

  • Python pandas.pivot_table.

  • Python pandas.wide_to_long.

  • Python pandas.DataFrame.pivot.

Examples

data(matrix, package = "AcidTest")

## DFrame ====
long <- melt(matrix)
print(long)
wide <- cast(long)
print(wide)

acidgenomics/r-acidplyr documentation built on July 4, 2025, 5:55 a.m.