I am trying to write a function that can be used to apply to process all the 
columns of a data.frame. If you will run the code below, you will get the error 
message undefined columns selected. I hope someone will be able to teach me 
what I am doing wrong.
Thank you,
John 
 
# create data frame.
guppy
 
fract2 <- function(col,data) {
  cat("Prove we have passed the data frame\n")
  print(data)
  
  # Get the name of the column being processed.
  zz<-deparse(substitute(col))
  cat("Column being processed\n")
  print(zz)
  p<-sum(data[,zz]!="")/length(data[,zz])
  return(p)
}
 
apply(guppy,2,fract2,data=guppy)
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
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 the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to