[R] Re: Re: List and Column Names in a Function?

khobson@fd9ns01.okladot.state.ok.us khobson at fd9ns01.okladot.state.ok.us
Fri May 13 19:47:30 CEST 2005

The R-Help replies inspired me to try ds(get("ds1"), "Y") which solves my

What I wanted was to pass string values for both the list name and the
column name.  I had tried several methods before posting.  Thanks for the

I incorrectly stated that Douglas Grove's solution would not work.  (I had
a typo when I tried it).  It works as he specified but not as I required.
The results below are the expected results which I probably should have
shown to be more clear.   It did get me to a solution though.

I would not post questions if I had not read the posting guide.   I spent
lots of time viewing the R-Help archives prior to posting as well.  Two
other posts of mine had no replies.  If you see those, there is no need to
reply.  With this more simplified example and your responses, I'm now good
to go.


> From: khobson at fd9ns01.okladot.state.ok.us
> The solution that Douglas proposed does not work.  Any other ideas?

Then perhaps you could (re-)read the posting guide, and give us more
information on what you mean by "does not work", and exactly what you are
expecting?  Isn't this what you want?

> ds1 <- c(X=list(1:10), Y=list(11:20))
> ds <- function(myds, vec) myds[[vec]] * 2
> ds(ds1, "Y")
 [1] 22 24 26 28 30 32 34 36 38 40

More information about the R-help mailing list