[R] comparing a vactor of values in IF statement.

From: Jagarlamudi, Choudary <choudary.jagar_at_swosu.edu>
Date: Sat 21 May 2005 - 03:58:34 EST


 my vector V<- c(1,0.5,0.06,0.056,0.01,0.04,0.4,0.9,0.82,0.1)  

  if( V > 0.5) { V <- 1 - V }  

I get a warning saying only the first element will be used in comparing (if V > 0.5). However, my results tell me vis-versa ,it actually compares every element of the vector V with 0.5 and that is waht i want it to do. Using a for loop is expensive and time consuming since my actual vector is 15000 values.  

Any help to rectify the warning i get is appreciated.  

Thank You.  

Choudary Jagarlamudi
Southwestern Oklahoma State University
STF 254
100 campus Drive
Weatherford OK 73096
Tel 580-774-7136

        [[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat May 21 04:01:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:58 EST