Venkatesh Is this what you are looking for?
# Example data df=data.frame(A=c(1,0,0,0,1),B=c(1,1,0,0,0),C=c(1,0,0,0,0),Val=c(1,0,1,0,1)) # Variation of code of David Winsemius tbl = lapply(df[, 1:3] , function(x) table(x, df$Val)) fet = lapply(tbl, function(x) fisher.test(x)) # Identify internal objects of fet names(fet$A) # get p values p.val = do.call(rbind,fet)[,1] p.val.df=data.frame(pval=matrix(unlist(p.val))) # get conf int ci = do.call(rbind,fet)[,2] ci.df=data.frame(matrix(unlist(ci),byrow=TRUE,ncol=2)) # add back id of letter id = data.frame(idletter=colnames(df[,-4])) # results res = data.frame(id,pvalue=p.val.df,confint=ci.df) There is undoubtly a more elegant way of handling getting the p-values and conf int than my attempt. HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/Fwd-R-apply-help-urgent-tp2164281p2164867.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.