Re: [R] creating cubes

2016-01-15 Thread Richard M. Heiberger
## I think you should look at the abind ## array bind ## function in the abind package. install.packages("abind") library(abind) ? abind ## the examples are comprehensive ## It allows constructions like these w <- matrix(1:6, 2, 3, dimnames=list(letters[1:2], LETTERS[3:5])) x <- w+10 y <- w+20 z

Re: [R] creating cubes

2016-01-15 Thread Dalthorp, Daniel
One possibility is to arrange it as a 3-dimensional array with two 5 x 5 matrices (i.e. a 5 x 5 x 2 array): arrD3<-array(dim=c(5,5,2)) # the first matrix is (e.g.) random normal deviates: mat1<-matrix(rnorm(25),nrow=5,ncol=5) # the second matrix is (e.g.) random uniform deviates: mat2<-matrix(ru

Re: [R] creating cubes

2016-01-15 Thread Matteo Richiardi
Hi Daniel, thanks for your answer. How can I populate the array with the matrixes? Suppose I want to populate it with 10 matrixes matrix(NA,5,5) Matteo On 15 January 2016 at 22:26, Dalthorp, Daniel wrote: > How about: D<-array(dim=c(d1, d2, d3))? > > > > On Fri, Jan 15, 2016 at 2:20 PM, Matteo

Re: [R] creating cubes

2016-01-15 Thread Dalthorp, Daniel
How about: D<-array(dim=c(d1, d2, d3))? On Fri, Jan 15, 2016 at 2:20 PM, Matteo Richiardi < matteo.richia...@gmail.com> wrote: > What is the best way to store data in a cube? That is, I need to create a > data structure D with three indexes, say i,j,h, so that I can access each > data point D[i

[R] creating cubes

2016-01-15 Thread Matteo Richiardi
What is the best way to store data in a cube? That is, I need to create a data structure D with three indexes, say i,j,h, so that I can access each data point D[i,j,h], and visualise sections like D[i,j,] or D[,,h]. I have tried to create an array of matrixes: D <-matrix(matrix(NA,i,j),h) but th