Skip to content
Prev 374781 / 398506 Next

Manipulation of data.frame into an array

Hello everyone,


 I want to transform a data.frame into an array (lets call it mydata), where: mydata[[1]] is the first imputed dataset...and for each mydata[[d]], the first p columns are covariates X, and the last one is the outcome Y.


Lets assume a simple data.frame:


Imputed = data.frame( X1 = c(1,2,1,2,1,2,1,2, 1,2,1,2,1,2,1,2),

                                          X2 = c(0,1,0,1,1,1,0,1, 0,1,0,1,1,1,0,1),

                                           Y   = c(1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8))

The first 8 have been obtained by the first imputation and the later 8 by the 2nd.


Can you help me please?


Best,

ioanna