Hi all, is it possible to create a multidemensional list? Haven't found anything in the list() help page. Thanks, Sven -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Sven, On Wed, 23 May 2001, Sven Garbade wrote:> is it possible to create a multidemensional list? Haven't found anything > in the list() help page.Yes it is, although there are some slight bugs to be aware of. If you have> fred <- as.list(1:12)then you can make fred into a dimensioned list simply by doing> dim(fred) <- c(3, 4)and then you can do things like> fred[[1, 2]] <- list(happy = 1:10, sad = "armadillo")There are a couple of things that don't work very well. At version 1.2.1 (a bit out of date but my latest version) you will get a segmentation fault if you do the incorrect> fred[[1, ]]but this has been corrected on later versions. It is still a bit difficult to make a dimensioned list by doing> array(list(happy = 1:10, sad = "armadillo"), c(3, 4))but that is because rep does not (yet) handle lists *except* simple lists like> array(list(happy = 1:10), c(3, 4))I believe that this is being addressed. But with ingenuity you can get around this, for example I have used a construction like> fred <- array(list(list(happy = 1:10, sad = "armadillo")), c(3, 4))Cheers, Jonathan. Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham Durham DH1 3LE tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388 http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Sven Garbade wrote:> > Hi all, > > is it possible to create a multidemensional list? Haven't found anything > in the list() help page.Lists can be elements of lists. So it is possible to generate a multidimensional structure by adding lists as elements to lists, which are elements of a list, .... Uwe Ligges BTW: The definition of arrays is multidimensional. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>> > is it possible to create a multidemensional list? Haven't found anything > in the list() help page. > > Thanks, SvenLists are always 1-dimensional. Length is measured by length(). Martin -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._