[R] Something wrong with my function Please Help
Chunhao Tu
tu_chunhao at yahoo.com
Tue Sep 29 05:29:37 CEST 2009
Hi R users,
I try to build a function to compute odds ratio and relative risk however
something wrong. I stuck for many hours but I really don't know how to solve
it. Would someone please give me a hint?
> OR.RR<-function(x){
+ x <- as.matrix(any(dim(x)==2))
+ OR<-(x[1,1]*x[2,2])/(x[1,2]*x[2,1])
+ RR<-(x[1,1]/(sum(x[1,])))/(x[2,1]/(sum(x[2,])))
+ return(OR);return(RR)
+ }
>
> tt<-matrix(data=1:4,nrow=2,ncol=2)
> OR.RR(tt)
Error in OR.RR(tt) : subscript out of bounds
Many Thanks
Tu
--
View this message in context: http://www.nabble.com/Something-wrong-with-my-function-Please-Help-tp25656420p25656420.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list