to_long: Reshape a data.frame or matrix to a long data.frame

Description Usage Arguments Value Author(s) Examples

View source: R/to_long.R

Description

Reshape a data.frame or matrix to a long data.frame

Reshape a data.frame or matrix to a wide data.frame

Usage

1
2
3
4
to_long(wide, rowname = NULL, colname = NULL,
  responseName = deparse(substitute(wide)), varNames = c("Row", "Col"))

to_wide(long, row = 1, col = 2, response = 3)

Arguments

wide

A data.frame or matrix in wide form

rowname

Name for the row variable

colname

Name for the column variable

responseName

Name for the response variable. If wide is a matrix with an attribute that begins with "response", that value is taken as the responseName. Otherwise, the name of the wide object is used.

varNames

Default names for the row and column variables if not passed as rowname or colname

long

A data.frame in long form

row

Column index or quoted name of the row variable

col

Column index or quoted name of the column variable

response

Column index or quoted name of the response variable

Value

A data.frame in long format

Author(s)

Michael Friendly and Richard M. Heiberger

Michael Friendly and Richard M. Heiberger

Examples

1
2
3
4
5
6
Arizona.long <- to_long(Arizona, varNames=c("Month", "City"))
Arizona.long

Arizona.long <- to_long(Arizona, varNames=c("Month", "City"))
# back the other way
to_wide(Arizona.long)

twoway documentation built on July 1, 2020, 5:37 p.m.

Related to to_long in twoway...