[R] Function Error

2008-07-22 Thread Angelo Scozzarella
Hi, Why this function doesn't work? function (x) { if (is.factor(x)) { if (!is.ordered(x)) { warning(La mediana non si puo' calcolare!!!) return(NA) } me - median(unclass(x)) if (me - floor(me) != 0) { warning(Mediana

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

Re: [R] Function Error

2008-07-22 Thread anna freni sterrantino
- Messaggio originale - Da: Angelo Scozzarella [EMAIL PROTECTED] A: r-help@r-project.org Inviato: Martedì 22 luglio 2008, 20:51:05 Oggetto: [R] Function Error Hi, Why this function doesn't work? function (x) { if (is.factor(x)) { if (!is.ordered(x)) { warning(La

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 of