reshapeLong-deprecated {base} | R Documentation |
(EXPERIMENTAL). Convert data frame with repeated measurements in wide format with repeated observations in multiple variables across rows to long format, 1 row per observation.
reshapeLong(x, jvars, ilev=row.names(x), jlev=names(x)[jvars], iname="reshape.i", jname="reshape.j", vname="reshape.v")
x |
The data frame to convert |
jvars |
The variables to reshape by |
ilev |
Levels of 1st indexing factor |
jlev |
Levels of 2nd indexing factor |
iname |
Name of 1st indexing factor |
jname |
Name of 2nd indexing factor |
vname |
Name of variable holding the combined values of the "across" variables |
This causes the values in jvars
to be combined into a single
variable, all other variables being replicated the relevant number of
times. Two factors are added to the data frame indicating rows and
columns of the original data format.
The reshaped data frame.
There ought to be a way to have multiple sets of
jvars
variables.
The same substitution tricks are used for jvars
as for the
select
argument to subset
. I.e. the argument is treated
as an expression and variables are replaced with their number in the
data frame, allowing ranges of variables to be specified.
(dd<-as.data.frame(matrix(1:24,4))) reshapeLong(dd,V3:V5)