[R] access a column of a dataframe without qualifying the name of the column

John Sorkin jsorkin at grecc.umaryland.edu
Thu Dec 30 01:11:09 CET 2010

I am trying to write a function that will access a column of a data frame without having to qualify the name of the data frame column as long as the name of the dataframe is passed to the function. As can be seen from the code below, my function is not working:

df <- data.frame(x=1:10,y=11:20)

test <- function(column,data) {


 I am trying to model my function after the way that lm works where one needs not qualify column names, i.e.

fit1<- lm(y~x,data=df)

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

More information about the R-help mailing list