On 29 Jan 2015, at 07:34 , Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote:

> This approach is fraught with dangers.
> 
> I recommend that you put all of those data frames into a list and have your 
> function accept the list and the name and use the list indexing operator 
> mylist[[DFName]] to refer to it. Having functions that go fishing around in 
> the global environment will be hard to maintain at best, and buggy at worst.

Agreed. However, just to help understand the issue: 
 
DFName is a length-one vector of character strings, not the object that has the 
name contained in the string. I.e. you can do nchar(DFName) and presumably get 
the value 7, but there is no operation on df.1001 that can tell you the length 
of its name. You can (but shouldn't, as per Jeff's note) get from name to 
object using get()/assign() and also via some concoctions involving 
combinations of eval(), parse(), as.name(), and substitute(). 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to