Learn R Programming

taRifx (version 1.0.6.2)

reshapeasy: reshapeasy: Easier reshaping from "wide" to "long" and back again

Description

reshapeasy is a wrapper around base R's reshape which allows for saner syntax. In particular, it makes it possible to reverse the operation by only specifying that the direction change (e.g. the names of the arguments are consistent between the direction of reshaping).

Usage

reshapeasy(data, direction,
    id = (sapply(data, is.factor) | sapply(data, is.character)),
    vary = sapply(data, is.numeric), omit = c("_", "."),
    vars = NULL, ...)

Arguments

data

A data.frame to be reshaped

direction

"wide" or "long"

vars

he names of the (stubs of) the variables to be reshaped (if omitted, defaults to everything not in id or vary)

id

The names of the variables that identify unique observations

vary

he variable that varies. Going to wide this variable will cease to exist. Going to long it will be created.

omit

vector of characters which are to be omitted if found at the end of variable names (e.g. price_1 becomes price in long)

...

Options to be passed to stats::reshape

Value

A data.frame