convert 3 dimensional array into dataframe
array
s and matrices
are vectors with dimensions, so recast to a matrix
, then data.frame
:
data.frame(matrix(result, nrow=2, byrow=TRUE))
# generalisably:
data.frame(matrix(result, nrow=dim(result)[3], byrow=TRUE))
# X1 X2 X3 X4 X5 X6 X7 X8 X9
#1 2 13 22 98 4 8 8 1 10
#2 2 4 6 7 1 55 32 12 1
You could try mapply
:
as.data.frame(mapply(function(x, y) c(x, y), result[,,1], result[,,2]))
# V1 V2 V3 V4 V5 V6 V7 V8 V9
#1 2 13 22 98 4 8 8 1 10
#2 2 4 6 7 1 55 32 12 1