[R] Function Error

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Jul 22 21:42:31 CEST 2008

2008/7/22 Angelo Scozzarella <angeloscozzarella at tiscali.it>:
> 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:

 which is because you haven't closed the "(" from the "return(" function.

 If you use an editor with syntax highlighting (emacs+ESS, tinn-R,
others) it will flash matching brackets and parentheses so you don't
make this kind of mistake.


More information about the R-help mailing list