Reshape Grouped Data to Long
Reshaping grouped data via melt
to 'long' format. The
responses are merged in one column, with its column name in an additional column.
This column is split into multiple columns, if a split character is given.
All predictors are merged multiple times corresponding to the number or responses.
reshapeLong( dataset = cs.in.dataset(), preds = cs.in.predictors(), resps = cs.in.responses(), scriptvars = cs.in.scriptvars(), return.results = FALSE, ... )
dataset |
[ |
preds |
[ |
resps |
[ |
scriptvars |
[ |
return.results |
[ |
... |
[ANY] |
One script variables is summarized in scriptvars
list:
[character(1)
]
Split character to split response names into multiple columns. Default is “_”.
Logical [TRUE
] invisibly and outputs to Cornerstone or,
if return.results = TRUE
, list
of
resulting data.frame
object:
reshapeLong |
Dataset with reshaped data. |
# Data to transform: library(data.table) dtTest = data.table(i_1 = c(1:4, NA, 5), i_2 = c(51, 61, NA , 71, 81, 91) , f1 = factor(sample(c(letters[1:3], NA), 6, TRUE)) , f2 = factor(c("z", "a", "x", "c", "x", "x"), ordered = TRUE) ) # Reshape to long format: reshapeLong(dtTest, c("i_1", "i_2"), c("f1", "f2"), list(split = "_"), return.results = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.