[18857] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] Mapping a character string into an object

daemon@ATHENA.MIT.EDU (fan@katan.cybercom.net)
Wed Aug 4 16:58:01 1999

From: fan@katan.cybercom.net
Date: Wed, 4 Aug 1999 16:48:43 -0400
Message-Id: <199908042048.QAA03405@katan.cybercom.net>
To: s-news@wubios.wustl.edu


I am working on producing a table of N rows. Each row contains
summaries for a different name, say "A", "B", ...
For each name, there are multiple data vectors corresponding to it.

Then, I apply some operations for these names, one at a time.
I am considering using a loop, so that codes can be
reused. In an attempt, I made a list:

namelist <- c("A", "B", ...)

The job I am thinking about has a diagram as:

for (i in 1:length(namelist))
{
	# call the variable named "namelist[i]" for computation.
        # this requires "a map from a string to an object"

	# An example is:
	# cat(a <- mean(*.c),"\t", b<-var(*.d), where * is the ith element of
	# namelist.
}

I don't know of a way to refer to different objects from within a loop
as iterator i changes. Please send in your ideas.

The reasons that I didn't combine all the data vectors into a big matrix/array
and then refer it via index are:

  1.duplicating data is consuming, especially when the dataset is large.
  2.multiple data-vectors for a certain name (e.g., A.c, A.d, A.e) may
    not have the same length.
  3.length(namelist) could be large.

Let me know if I haven't described the problem well.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post