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

Description Usage Arguments Value Author(s)

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

1
2
3
4
  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

Author(s)

Written with the help of the StackOverflow R community, see http://stackoverflow.com/questions/10055602/wrapping-base-r-reshape-for-ease-of-use


gsk3/taRifx documentation built on May 17, 2019, 8:55 a.m.