| umx_wide2long | R Documentation |
Makes wide data long using reshape
Hopefully a more robust interface to reshape()
For twin data, this calls umx_wide2longTwinData(data =data, sep = sep, verbose = verbose)
umx_wide2long(
data = df,
timevar = list(condition = c("control", "expt")),
repeated = list(example = c("easyexample", "hardexample"), grade = c("grd1", "grd2")),
covs = c("Age", "Sex"),
idvar = "PID",
sep = "_T",
verbose = FALSE
)
data |
A data.frame to make long. |
timevar |
A list of the conditions individuals are in that generate repeated measures, list(condition = c("control", "expt")) |
repeated |
A list of varied inputs and their levels: i.e., list(exam = c("easy", "hard"), ...) |
covs |
A vector of variables that do not vary, e.g., c("Age", "Sex", "IQ"). |
idvar |
The column containing the unique ID of the subjects "PID". |
sep |
For twin data - calls = umx_wide2longTwinData default "_T" |
verbose |
Whether to be verbose (FALSE) |
This is for processing data in which subjects (identified by a idvar column, have repeated measures on one or more outcomes.
The goal is to make the data into long format, for passing to functions like lme4::lmer().
You must:
Set timevar. This is a list of the conditions that you repeated. The name becomes a column in the long output. e.g., list(difficulty = c("easy", "hard"))
Set repeated This is a list of the measured outcomes, e.g. list(DV = c("NASA1_frust", "NASA2_frust"), effort = c("NASA1_eff", "NASA2_eff"))
Set covs This is vector of non-repeated non-varying IVs c("age", "sex", "IQ").
Table: The resulting output is like this:
| idvar | condition | Age | DV |
| 001 | "easy" | 45 | 10 |
| 001 | "hard" | 45 | 75 |
| 002 | "easy" | 19 | 54 |
| 002 | "hard" | 19 | 74 |
a long version of the df.
reshape()
Other Miscellaneous Utility Functions:
install.OpenMx(),
libs(),
qm(),
umx,
umxLav2RAM(),
umxModelNames(),
umxRAM2Lav(),
umxVersion(),
umx_array_shift(),
umx_find_object(),
umx_lower.tri(),
umx_msg(),
umx_open_CRAN_page(),
umx_pad(),
umx_print(),
umx_wide4lmer()
## Not run:
timevar = list(difficulty = c("easy", "hard"))
repeated = list(
frustration = c("NASA1_frustration", "NASA2_frustration"),
effort = c("NASA1_effort", "NASA2_effort")
)
df.l = umx_long2wide(data, timevar, repeated, covs = c("Age"), idvar = "PID")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.