rearrange: rearrange a data frame from wide to long format

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

This utility function of the erpR package converts an ERP data frame with a single variable in wide format to a long format.

Usage

1
rearrange(deps, oth = NULL, dataset, name.dep = "Dep", name.newvar = "New_Var")

Arguments

deps

the numbers of the columns in the specified data frame to be rearranged from wide format to long format.

oth

other variables that are to be kept in the returned data frame.

dataset

the name of the data frame to be converted from wide format to long format.

name.dep

the name of the dependent variable in the returned data frame.

name.newvar

the name of the variable indicating the levels associated with name.dep in the returned data frame.

Details

The function converts a dataframe with a single variable in wide format (levels are in separate columns) in a data frame in long format (the variable is in a single column and the levels are specified by other columns). The original variable in wide format is represented in two columns: one (labeled by name.dep parameter) indicating the values of the dependent variable, and the other that is a factor (labeled by name.newvar parameter) indicating the levels of the variable for each observation. The variables specified in oth are replicated appropriately. This function is called internally by erp.mean, erp.peak, and erp.latency.

Value

A data frame in which the variables specified in the columns deps are converted in a single column name.dep with levels specified in name.newvar

Note

This function is called internally by erp.mean, erp.peak, and erp.latency.

Author(s)

Giorgio Arcara

See Also

erp.mean, erp.peak, erp.latency

Examples

1
2
3
4
5
6
data(erplistExample)

datwide=erp.mean(base="Exp1_word_subj", numbers=1:20, win.ini=130, 
win.end=190, erplist=erplistExample, startmsec=-200, endmsec=1500, format="wide")

dat.long=rearrange(deps=c(1:32), oth=35:36, dataset=datwide, name.newvar="electrode")

erpR documentation built on June 7, 2019, 3 a.m.