Skip to content
Prev 246005 / 398503 Next

access a column of a dataframe without qualifying the name of the column

?substitute

test <- function(col,frm) {
  eval(substitute(col),frm)
}

test2 <- function(col,frm){
  cname<- deparse(substitute(col))
  frm[[cname]]
}

 z <- data.frame(x=1:3,y=letters[1:3])

test(x, z)

test2(x, z)


-- Bert
On Wed, Dec 29, 2010 at 4:44 PM, David Winsemius <dwinsemius at comcast.net> wrote: