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

From: <>
Date: Sat 14 May 2005 - 03:47:30 EST

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

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 replies.

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:
> 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 mailing list PLEASE do read the posting guide! Received on Sat May 14 03:52:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:45 EST