[18867] in s-news-athena
[S] re: Mapping a character string into an object
daemon@ATHENA.MIT.EDU (fan@katan.cybercom.net)
Thu Aug 5 10:36:26 1999
From: fan@katan.cybercom.net
Date: Thu, 5 Aug 1999 10:33:09 -0400 (EDT)
To: s-news@wubios.wustl.edu
Message-Id: <Pine.LNX.4.04.9908051030090.26733-100000@katan.cybercom.net>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Upon respondents's suggestions, get() and paste()
get the work done. I was not not aware of the "get" function.
Thanks- Fan
-----Original Message-----
From: fan@katan.cybercom.net [mailto:fan@katan.cybercom.net]
Sent: Wednesday, August 04, 1999 9:49 PM
To: s-news@wubios.wustl.edu
Subject: [S] Mapping a character string into an object
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
-----------------------------------------------------------------------
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