[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:01:08 CEST 2005

The solution that Douglas proposed does not work.  Any other ideas?

> In this simple function, how can I pass strings for index and column
> to the function?  I've posted this type of question before and received
> response.
> Maybe this example will be easier to understand and troubleshoot.
> ds <- function(myds, vec) {myds[[vec]]*2}
> ds1 <- c(X=list(1:10), Y=list(11:20))
> ds(get("ds1"),get("Y"))

You are overusing the get function.  I think you can do what you want as

ds(ds1, "Y")

khobson at odot.org
Kenneth Ray Hobson, P.E.
Oklahoma DOT - QA & IAS Manager

More information about the R-help mailing list