[R] problem with "any" function

Matthias Gondan matthias-gondan at gmx.de
Sat Nov 17 20:55:36 CET 2012


The warning

1: In (ind.c == TRUE) & (ind.sgn == TRUE) :
    longer object length is not a multiple of shorter object length

means that ind.c and ind.sgn have different lengths, for whatever reason.
Although R continues the routine, the warning should, in general, not be 
ignored.

Try:
1:3 + 1:2
at the command prompt to see what type of unintended things happen.

Actually, 1:4 + 1:2 is running silently.

Best wishes,

Matthias

Am 17.11.2012 19:56, schrieb Rui Barradas:
> Hello,
>
> First of all, that's not an error message, it's a warning.
> As for your condition, it's too complicated. You don't need to test a
> logical value for equality to TRUE, it's redundant. And any(x, y) is
> equivalent to any(x, y, x & y). Try
>
> any(ind.c, ind.r, ind.sgn)
>
> and you'll be fine.
>
> Hope this helps,
>
> Rui Barradas
> Em 17-11-2012 18:36, Haris Rhrlp escreveu:
>> Dear R users,
>>
>> I have the "any" function of R
>>
>> any(ind.c, ind.r, ind.sgn)
>>
>>
>> all are logical factors
>>
>> it works fine when any of three is true
>> but when they are combined it doesnt work.
>>
>> i tried
>> this
>> any(ind.c, ind.r, ind.sgn,((ind.c==TRUE) & (ind.r==TRUE)),
>> ((ind.c==TRUE) & (ind.sgn==TRUE)),((ind.r==TRUE) & (ind.sgn==TRUE)),
>>    ((ind.c==TRUE) & (ind.r==TRUE) & (ind.sgn==TRUE)))
>> }
>>
>> but i have this error message
>> Warning messages:
>> 1: In (ind.c == TRUE) & (ind.sgn == TRUE) :
>>     longer object length is not a multiple of shorter object length
>> 2: In (ind.c == TRUE) & (ind.r == TRUE) & (ind.sgn == TRUE) :
>>     longer object length is not a multiple of shorter object length
>>
>> I want  to check combined  the three logikal factors
>>
>> any help will be welcome
>> 	[[alternative HTML version deleted]]
>>
>>
>>
>> ______________________________________________
>> 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.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.




More information about the R-help mailing list