I like Jeff's comments on the previous post.
Regarding Alan's question, please see the following example.
df.1 - data.frame(v1=1:5, v2=letters[1:5])
df.2 - data.frame(v1=LETTERS[1:3], v2=11:13)
DFName - ls(pattern = glob2rx(df.*))[1]
DFName
[1] df.1
length(DFName[,1])
Error in DFName[, 1]
That's fine, but I'm here in town if you want me to pick her up at the airport.
David
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chel Hee Lee
Sent: Thursday, January 29, 2015 9:18 AM
To: Jeff Newmiller; Alan Yong; r-help@r-project.org
Subject: Re:
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
Much thanks to everyone for their recommendations! I agree that fishing in the
global environment isn't ideal only shows my budding understanding of R.
For now, I will adapt Chel Hee's length(eval(parse(text=DFName))[,1])
solution then fully explore Jeff's suggestion to put the data frames
On Thu, Jan 29, 2015 at 11:43 AM, Alan Yong alany...@caltech.edu wrote:
Much thanks to everyone for their recommendations! I agree that fishing in
the global environment isn't ideal only shows my budding understanding of R.
For now, I will adapt Chel Hee's
Much thanks, Hadley!
Cheers,
Alan
On Jan 29, 2015, at 12:36 PM, Hadley Wickham wrote:
On Thu, Jan 29, 2015 at 11:43 AM, Alan Yong alany...@caltech.edu wrote:
Much thanks to everyone for their recommendations! I agree that fishing in
the global environment isn't ideal only shows my budding
Dear R-help,
I have df.1001 as a data frame with rows columns of values.
I also have other data frames named similarly, i.e., df.*.
I used DFName from:
DFName - ls(pattern = glob2rx(df.*))[1]
would like to pass on DFName to another function, like:
length(DFName[, 1])
however, when I run:
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
8 matches
Mail list logo