[R] Pass character vector to function argument

David Winsemius dwinsemius at comcast.net
Tue Nov 16 18:07:05 CET 2010


On Nov 16, 2010, at 10:34 AM, Kevin Ummel wrote:

> A bit embarrassed to post this seemingly trivial question, but I  
> can't find anything in the archive that's quite relevant:
>
> a1=1
> a2=2
>
> obs=objects(pattern=glob2rx("a?"))
>
> I want to utilize 'obs' as a function argument to produce something  
> like:
>
> sum(a1,a2)
>

?get
 > sum(sapply(obs, get))
[1] 3


> Obviously, sum(obs) doesn't work, but I've tried variations of  
> 'eval', 'parse', 'mget', and 'noquote' without success. What am I  
> missing?
>
> Thanks,
> Kevin
>
-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list