reshape.long: Reshape from Wide to Long Format

Description Usage Arguments Details Value


Reshape data frames from wide to long format.


reshape.long <- function(data, varying.list, idvar = "id",
	ids = rownames(data), = "time",
	within.levels = c("colnames","integers","letters"), drop=NULL)



A data frame in wide format.


A named list of character vectors. Each vector of this list will contain the names of the variables in data that correspond to a single variable in the long format, and the name of the vector will be the name of that new variable.


Name of the variable in data that identifies each individual, or if that variable does not exist, the name of a newly created variable that will contain that information in long format (assuming that each row of data is a different individual).


Values to use for a newly created idvar variable in long format.

Character string with the name of the within-subjects factor, that will be created in long format for differentiating multiple records from the same individual.


What will be the levels of the within-subjects factor (see Details).


Variables of data that will be dropped in long format.


This is a wrapper of stats::reshape with direction="long". It admits duplicated values in idvar, and the default values of ids and times are different. The argument times of reshape is defined according to the value of within.levels: "colnames" means that times will be the names of the first set of variables defined in varying.list; for "integers", they will be a sequence of integers (as the default value in reshape); for "letters" they will be an alphabetical list starting from "a" (limited to 26 levels).


Reshaped data frame.

DeducerReshape documentation built on May 2, 2019, 5:20 p.m.