Re: [R] Function Error

From: Barry Rowlingson <b.rowlingson_at_lancaster.ac.uk>
Date: Tue, 22 Jul 2008 20:42:31 +0100

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:
":(cl-1)]))/(x$densit[cl]*N)

   }"

 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.

Barry



R-help_at_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. Received on Tue 22 Jul 2008 - 20:41:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Jul 2008 - 21:32:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive