[R] Odp: problem with using %in% condition while using in if() condition

Petr PIKAL petr.pikal at precheza.cz
Thu Feb 19 08:02:53 CET 2009


Hi

r-help-bounces at r-project.org napsal dne 19.02.2009 07:15:00:

> Hi all,
> I got one problem with using %in% condition while using in if() 
condition
> where
> I used the condition as
> 
> 
> if(SubFinSpt$SPECIMENTYP %in% CAP$SPECIMENTYP)

SubFinSpt$SPECIMENTYP %in% CAP$SPECIMENTYP

gives you logical vector

"if" works only with the first value of this vector

see

?"if"
?"ifelse"

Regards
Petr


> 
> this   "if()"    condition is in      "else"     condition
> and hear  "*SubFinSpt$SPECIMENTYP*" having only one value   but
> "*CAP$SPECIMENTYP"
> *having nearly 20 SPECIMENTYP's
> 
> while applying this condition I got one warning that says  only first
> element is checked
> and after that warning it is executing normally and giving results
> but i want to know why it is giving this warning
> 
> can any one explain why it is comming and how to resolve it
> 
> thanks in advance
> 
>    [[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