Re: [R] Function Error

2008-07-22 Thread Barry Rowlingson
2008/7/22 Angelo Scozzarella <[EMAIL PROTECTED]>: > Hi, > > Why this function doesn't work? >return(x$breaks[cl]+ >(N/2-sum(x$counts[1:(cl-1)]))/(x$densit[cl]*N) >} else median(x) > } Have you read the error message? I get: Error: unexpected '}' in: ":(cl-1)]))/(x$densit[cl]*

Re: [R] Function Error

2008-07-22 Thread Sarah Goslee
At a first guess, because you are missing a right paren in thereturn() statement of the final else section. Otherwise, we'd need to know about what "doesn't work" means - what is x supposed to be? What do you want the function to do? What error messages are you getting? You haven't provided any o

Re: [R] Function Error

2008-07-22 Thread anna freni sterrantino
Hi Angelo, please read the posting guide, before posting! Anyway, for general rule, if you want to see what's going on in a function at each step, it may be helpful to install library("debug") that has very useful functions as "mtrace" that my resolve your problem. Cheers Anna

Re: [R] Function Error

2008-07-22 Thread Erik Iverson
Please give commented, minimal, self-contained, reproducible code. In this case, not only the function definition, but a simple example showing *how* it does not work, and what you were expecting it to do! Angelo Scozzarella wrote: Hi, Why this function doesn't work? function (x) { if (