set.seed(123)
data <- data.frame(ID = 1:10,
weight_hus = rnorm(10, 0, 1),
weight_wife = rnorm(10, 0, 1),
height_hus = rnorm(10, 0, 1),
height_wife = rnorm(10, 0, 1))
I am trying to use reshape() function
(due to some reasons, I can not use tidyverse function or other packages' function. wanna use reshape() function)
data2 <- reshape(data = data,
idvar = "ID",
seperator = "_",
direction = "long",
v.name = c("body"),
timevar = c("hus", wife)
)
but it never works...
Here is the code:
Changes made:
seperatorwithvaryingto specify the variables to be reshaped.v.namesto provide meaningful names for the reshaped variables.timevarto "gender" to represent the different groups ("hus" and "wife").