This conveniently wraps melting and (d)casting a data frame into a single step.

recast(data, formula, ..., id.var, measure.var)

Arguments

data

data set to melt

formula

casting formula, see dcast for specifics

...

other arguments passed to dcast

id.var

identifying variables. If blank, will use all non measure.var variables

measure.var

measured variables. If blank, will use all non id.var variables

Examples

recast(french_fries, time ~ variable, id.var = 1:4)
#> Aggregation function missing: defaulting to length
#>    time potato buttery grassy rancid painty
#> 1     1     72      72     72     72     72
#> 2     2     72      72     72     72     72
#> 3     3     72      72     72     72     72
#> 4     4     72      72     72     72     72
#> 5     5     72      72     72     72     72
#> 6     6     72      72     72     72     72
#> 7     7     72      72     72     72     72
#> 8     8     72      72     72     72     72
#> 9     9     60      60     60     60     60
#> 10   10     60      60     60     60     60