This works, but then I can only save a single matrix in each
database[x,y] while I need to save a list of matrices.
Gabor Grothendieck schrieb:
Try this:
database[[4,4]] <- tetrahedron
database[[4,4]][1,]
[1] 0 1 1 1
On Wed, Aug 19, 2009 at 6:02 AM, Michael Kogan<michael.ko...@gmx.net> wrote:
Unfortunately the matrix(list(),x,y) way seems to have some limitations. I
want to continue working with the matrices which are saved in the database
matrix. But for example the following doesn't work:
tetrahedron=matrix(c(
0,1,1,1,
1,0,1,1,
1,1,0,1,
1,1,1,0
),nrow=4, byrow=TRUE) # an example matrix
database=matrix(list(),5,5) # create database matrix
database[[4,4]]=list(tetrahedron) # save example matrix in database matrix
## try to access the first row of the saved example matrix ##
database[[4,4]][1] # prints the whole example matrix
database[[4,4]][1][1,] # should have printed the first row of the example
matrix, but gives:
Error in database[[4, 4]][1][1,] : incorrect number of dimensions
Execution halted
The same happens with database[[4,4]][1,]... Is there any way to access the
saved matrices like "normal" ones?
Thanks,
Michael
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.