On Tue, Sep 29, 2009 at 4:29 AM, Chunhao Tu <tu_chun...@yahoo.com> wrote: > > 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){
What is this line doing: x <- as.matrix(any(dim(x)==2)) If you run it on your 2x2 matrix you get this: > as.matrix(any(dim(tt)==2)) [,1] [1,] TRUE and then the rest of your code is working with that value of 'x', and so failing. I don't know what that line is there for - what do you think it is doing? You shouldn't get stuck for hours over something this simple. Try each line on its own and check the return value is what you think it should be. You can either type each line in to the > prompt, or learn to use the 'debug' function. See help(debug) for more. Barry ______________________________________________ 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.