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 Andy
In this simple function, how can I pass strings for index and column
names
to the function? I've posted this type of question before
and received no
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
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html