Skip to content
Prev 172482 / 398506 Next

Odp: nice way to find or not a value (problem with numeric(0))

Hi

r-help-bounces at r-project.org napsal dne 04.03.2009 09:11:06:
don't
like
%in%
more
It is a bit cryptic what do you want. Above version shall not work as it 
takes only one logical value but you probably have vector of values. (We 
do not know code, spec$Code or any other data you have).

when I try your first construction with some values I have I get sensible 
results so without trying to find out how your data really look like I 
suggest you to inspect it more closely and/or provide some working example 
demonstrating what you did, what is the result and how the result shall 
look like.

zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2))
 [1] 110  80  50  50  10   1 120  80  50  20
zdrz$otac[5]<-NA
zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2))
 [1] 110  80  50  50   1   1 120  80  50  20
zdrz$sklon[4]<-Inf
zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2))
 [1] 110  80  50 Inf   1   1 120  80  50  20
zdrz$sklon[4]<-NA
zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2))
 [1] 110  80  50  NA   1   1 120  80  50  20

Regards
Petr
http://www.nabble.com/nice-way-to-find-or-not-a-
http://www.R-project.org/posting-guide.html