Message-ID: <F4F94B86-2EAA-4824-AEED-B0ACAFF7636A@gmail.com>
Date: 2009-02-05T22:10:01Z
From: Fuchs Ira
Subject: eval and as.name
I'm sure there is a more general way to ask this question but how do
you use the elements of a character vector as names of objects in an
expression?
For example, say you have:
a = c(1,3,5,7)
b = c(2,4,6,8)
n=c("a","b")
and you want to use the names a and b in a function (e.g. sum)
sum(eval(as.name(n[1])),eval(as.name(n[2])))
works but
what is a simpler way to effect this level of indirection?