[R] check without loop
Scott, Uriel
uriel.scott at mirant.com
Wed Mar 20 19:45:33 CET 2002
I think the which() function would be helpful. For example if x is a vector
and c some value then
> which( x == c )
will return a vector of those indices i of x for which x[i] = c. Then you
can test whether that vector
has length 0.
> -----Original Message-----
> From: jimi adams [SMTP:imij at columbus.rr.com]
> Sent: Wednesday, March 20, 2002 11:41 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] check without loop
>
> i am probably just missing this one, but how can i check to see if a
> number
> is a part of a vector?
>
> i know i could do a loop checking for equivalence for each element, but i
> am
> thinking that there must be a simpler way to do it than that ( i think
> that
> i have even done it in the past, but can't remember how!)
> thanks
>
> what i am working with:
> (hope this makes sense)
>
> arclist
> [1] 2 2 6 7 8 9 9 11 11 11 12 13 14 15 16 17 19
> 21
> [19] 22 23 24 25 25 29 29 30 32 34 35 35 38 39 40 40 41
> 42
> [37] 43 44 45 46 47 48 49 50 51 52 53 54 57 58 59 60 61
> 61
> [55] 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
> 61
> [73] 61 61 61 61 61 61 61 61 61 61 62 65 67 68 68 69 71
> 72
> [91] 75 76 77 79 81 82 83 84 84 85 86 87 88 90 91 92 93
> 94
> [109] 95 96 96 96 96 100
>
> # and am sampling from a different list
> # if i draw, say 80, i would then not want to proceed, but if i draw a
> number on arclist i do
>
>
>
> jimi adams
> Department of Sociology
> The Ohio State University
> 300 Bricker Hall
> 190 N Oval Mall
> Columbus, OH 43210-1353
> 614-688-4261
>
> our mind has a remarkable ability to think of contents as being
> independent
> of the act of thinking
> -georg simmel
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-
> r-help mailing list -- Read
> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list