Re: [R] Error:non-numeric argument in my function

2009-06-02 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > > interestingly, > > as.complex('0i') > # NA > but as.complex('0+0i') # 0+0i so that while just 0i is valid as a complex literal, '0i' is not valid as a string representing a complex. easy to learn and use. of course, eval(parse(text='0i'))

Re: [R] Error:non-numeric argument in my function

2009-06-02 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: > I agree that it's inconsistent that > 1:'2' --> 1:2 # this doesn't seem to be documented in ? seq > 1+ '2' --> error > 1+factor(2) --> NA (with a warning) > 1 : factor(4) --> 1 (uses as.numeric/unclass of factor) > > > >> ...i'd expect ...

Re: [R] Error:non-numeric argument in my function

2009-06-02 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: > On Mon, Jun 1, 2009 at 11:33 AM, Wacek Kusnierczyk < > waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > > >> ... there is an ugly lack of consistency here:... >> >> > > I agree that it's inconsistent that > > 1:'2' --> 1:2 # this doesn't seem to be documen

Re: [R] Error:non-numeric argument in my function

2009-06-01 Thread Stavros Macrakis
On Mon, Jun 1, 2009 at 11:33 AM, Wacek Kusnierczyk < waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > ... there is an ugly lack of consistency here:... > I agree that it's inconsistent that 1:'2' --> 1:2 # this doesn't seem to be documented in ? seq 1+ '2' --> error 1+facto

Re: [R] Error:non-numeric argument in my function

2009-06-01 Thread Wacek Kusnierczyk
i think the error message might be even better, but this would require '* to be even better. i know some will take it for lamenting: there is an ugly lack of consistency here: 1:2 # 1 2 1:2.5 # 1 2 (coercion double -> integer) 1:'2' # 1 2 (corecion character -> integer)

Re: [R] Error:non-numeric argument in my function

2009-06-01 Thread Stavros Macrakis
Agreed, that's even better, e.g. Error in 1 * "a" : character argument not allowed for arithmetic operator * For some reason (does anyone know the rationale?), in the case of factors, you don't get an error, but a more explicit warning and an NA result: > 2*factor(3) [1] NA Warning message:

Re: [R] Error:non-numeric argument in my function

2009-06-01 Thread Patrick Burns
I thought Stavros' suggestion was going to be to have the error message say what type of offending object was found. If the message said that a list of class 'data.frame' was found (probably the leading case), then that would be much more helpful. Patrick Burns patr...@burns-stat.com +44 (0)20 8

Re: [R] Error:non-numeric argument in my function

2009-05-31 Thread jim holtman
What you need to do is to see that is in 'wekt_n_ok' at that point in your program. You should be able to see it with str(wekt_n_ok) when the error occurs. You can also add a print statement in the loop to print out the value before it is used with the binary operator. It would help if you provi

Re: [R] Error:non-numeric argument in my function

2009-05-31 Thread GrzeĊ›
Thanks jholtman! But I'm not sure what and where I should change my code... :( wekt_n = ndf[i,] wekt_n_ok = wekt_n[!is.na(wekt_n)] If before this line I should change "wekt_n_ok" as numeric? but if I wrote as.numeric(wekt_n_ok) it's also not correct and I also don't understand why "wekt_n_ok

Re: [R] Error:non-numeric argument in my function

2009-05-31 Thread Stavros Macrakis
On Sun, May 31, 2009 at 6:10 PM, jim holtman wrote: > Message is very clear: > > > 1 * 'a' > Error in 1 * "a" : non-numeric argument to binary operator Though the user should have been able to figure this out, perhaps the error message could be improved? After all, it is not the fact that the o

Re: [R] Error:non-numeric argument in my function

2009-05-31 Thread jim holtman
Message is very clear: > 1 * 'a' Error in 1 * "a" : non-numeric argument to binary operator "wekt_n_ok " must be non-numeric. You need to provide a reproducible script. You also need to learn about debugging. 'str(wekt_n_ok )' when the error occurred may have helped to pinpoint the problem. On