Message-ID: <4284CAC4.8010109@stat.wisc.edu>
Date: 2005-05-13T15:41:56Z
From: Douglas Bates
Subject: List and Column Names in a Function?
In-Reply-To: <OF6320598D.4E430D43-ON86257000.0053D7E4-86257000.00548ACE@fd9ns01.okladot.state.ok.us>
khobson at fd9ns01.okladot.state.ok.us wrote:
>
>
>
> 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")