Avoiding the infamous “eval(parse())” construct
Ok, so I'm running some loops to process data stored in list objects. Ever mindful of the infamous fortune admonishment not to use eval(parse(mystring)) , I came up with this: Rgames> bar $foo $foo$fast [1] 1 2 3 4 5 $foo$slow [1] 6 7 8 9 10 $oof $oof[[1]] [1] 6 7 8 9 10 $oof[[2]] [1] 1 2 3 4 5 Rgames> rab<-'bar' Rgames> do.call('$',list(as.name(rab),'oof')) [[1]] [1] 6 7 8 9 10 [[2]] [1] 1 2 3 4 5 Typically I'd be selecting a list (of which bar is one such) and then one element of the list (e.g. oof ) which contains my data. The code above does the same thing as eval(parse(text=paste(rab,'$',