[R] Dictionaries with integer indices

Ross Boylan ross at biostat.ucsf.edu
Mon Feb 13 22:24:11 CET 2006


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

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
d[[id]]
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                               ross at biostat.ucsf.edu
Dept of Epidemiology and Biostatistics           fax: (415) 514-8150
University of California, San Francisco
San Francisco, CA 94107-1739                     hm:  (415) 550-1062




More information about the R-help mailing list