Skip to content

help with for loop to test for a condition in a vector

2 messages · scoyoc, David Winsemius

#
I want my for loop to test for the presence of a term in a vector and return
a value to a new vector. I'm not writing it correctly though. Here's what I
have...
+   v = any(x == testfor[i])
+   result[i] = v
+ }
a  b  c  d  e 
NA NA NA NA NA NA NA NA NA NA 

I would like to get....
TRUE TRUE TRUE FALSE FALSE

Thanks,
MVS



-----
MVS
=====
Matthew Van Scoyoc
Graduate Research Assistant, Ecology
Wildland Resources Department & Ecology Center
Quinney College of Natural Resources
Utah State University
Logan, UT
=====
Think SNOW!


--
View this message in context: http://r.789695.n4.nabble.com/help-with-for-loop-to-test-for-a-condition-in-a-vector-tp4649213.html
Sent from the R help mailing list archive at Nabble.com.
#
On Nov 10, 2012, at 2:07 PM, scoyoc wrote:

            
Looks like yu want the first of these:
[1]  TRUE  TRUE  TRUE FALSE FALSE
[1]  TRUE  TRUE FALSE FALSE  TRUE