Dictionaries with integer indices

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Dictionaries with integer indices

Ross Boylan
Some past threads have pointed out that lists can be used as
dictionaries storing data with an associated key (environments do this

I have the seemingly simpler case with integer values for the
indices--however, the integers are not necessarily contiguous low
numbers.  My concern is that if id is 3000 then
d <- list()
d[[id]] <- some data

and later retrieval with
is going to be wasteful (e.g., produce something with 3000 elements).

I could turn id into a string, but that seems pretty indirect.

Is there any problem with the naive scheme outlined above?  If so,
what's a good way around it?
Ross Boylan                                      wk:  (415) 514-8146
185 Berry St #5700                               [hidden email]
Dept of Epidemiology and Biostatistics           fax: (415) 514-8150
University of California, San Francisco
San Francisco, CA 94107-1739                     hm:  (415) 550-1062

[hidden email] mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html