[R] Could graph objects be stored in a "two-dimensional list"?

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Thu May 23 18:06:27 CEST 2013

You could use lists of lists, and index them with vectors.

a <- list()
a[[1]] <- list()
a[[2]] <- list()
a[[c(1,1)]] <- g11
a[[c(1,2)]] <- g12
a[[c(2,1)]] <- g21
a[[c(2,2)]] <- g22

but this seems like an inefficient use of memory because your indexed data is stored more compactly than the graph object is. I would index the data and generate the graph object on the fly when I wanted to see it.
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

jpm miao <miaojpm at gmail.com> wrote:

>I have a few graph objects created by some graphic package (say,
>which I use frequently). Because of the existent relation between the
>graphs, I'd like to index them in two dimensions as p[1,1], p[1,2],
>p[2,2] for convenience.
>To my knowledge, the only data type capable of storing graph objects
>any R object) is list, but unfortunately it is available in only one
>dimension. Could the graphs be stored in any two-dimensional data type?
>  One remedy that comes to my mind is to build a function f so that
>With functions f and f^{-1} (inverse function of f) , the
>indices could be mapped to and from a set of one-dimensional indices,
>the functions are exactly the way R numbers elements in a matrix. Does
>have this built-in function for a m by n matrix or more generally,
>array? (I know this function is easy to write, but just want to make
>whether it exists already)
>   Thanks,
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list