[R] Creating object referant from argument name

2009-10-13 Thread showa
Hi all. I'd like to define an object within a function based on an argument to that function. Specifically, I've got: do.something<-function(input){ id<-substring(input,3,3) j<-list1 if(id==2)j<-list2 if(id==3)j<-list3 if(id==4)j<-list4 ...} Instead of all these if() arguments, I was hoping to u

Re: [R] Creating object referant from argument name

2009-10-12 Thread jim holtman
try this: (?get) j<- get(paste("list",substring(input,3,3),sep="")) On Mon, Oct 12, 2009 at 4:14 PM, Maxwell Reback wrote: > Hi all. I'd like to define an object within a function based on an > argument to that function. > Specifically, I've got: > > do.something<-function(input){ > id<-substri

Re: [R] Creating object referant from argument name

2009-10-12 Thread Rolf Turner
On 13/10/2009, at 9:14 AM, Maxwell Reback wrote: Hi all. I'd like to define an object within a function based on an argument to that function. Specifically, I've got: do.something<-function(input){ id<-substring(input,3,3) j<-list1 if(id==2)j<-list2 if(id==3)j<-list3 if(id==4)j<-list4 ...} In

[R] Creating object referant from argument name

2009-10-12 Thread Maxwell Reback
Hi all. I'd like to define an object within a function based on an argument to that function. Specifically, I've got: do.something<-function(input){ id<-substring(input,3,3) j<-list1 if(id==2)j<-list2 if(id==3)j<-list3 if(id==4)j<-list4 ...} Instead of all these if() arguments, I was hoping to us