16
  > str(mylist)
         List of 50
      $ : logi [1:14] 0.2 0.3 0.2 ...
      $ : logi [1:14] 0.1 0.3 0.6 ...
      $ : logi [1:14] 0.2 0.9 0.1 ...

I want to convert (or write out) mylist to 14 matrices with dim 5 10 or one array with dim 5 10 14

Example data:

mylist <- lapply(1:50, function(i) sample((1:14)/10, 14, repl=TRUE))
0

1 Answer 1

27

This will produce the desired array (with NAs for the nonnumeric values):

array(as.numeric(unlist(mylist)), dim=c(14, 5, 10))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.