[R] Hmisc, summary.formula and catTest

moleps moleps2 at gmail.com
Thu Jan 6 23:12:43 CET 2011


Dear all,

I´m specifying the fisher.exact test for use with summary.formula as follows:




u<-function(a,b){
	
	j<-fisher.test(a)
	p<-list(P=j$p.value,stat=NA,df=NA,testname=j$method,statname="")
	return(p)
	
	}

However I´m also required to specify stat & df. However this doesnt apply to the fisher test. I´ve tried specifying them as NA and "" without success-throws either a blank or an error msg trying to round a non-numeric value respectively.



reproducible example:
ex<-pbc
summary(trt~sex+ascites,data=ex,test=T,method="reverse")

summary(trt~sex+ascites,data=ex,test=T,method="reverse",catTest=u)


The closest I get is 


u<-function(a,b){
	
	j<-fisher.test(a)
	p<-list(P=j$p.value,stat=1,df=1,testname=j$method,statname="")
	return(p)
	
	}

However then I manually have to edit the output. Is there a smart way of doing this?

//M



More information about the R-help mailing list