[R] Hash Table - Select and Change Data iniside Matrix Using "Between"

Rantony antony.akkara at ge.com
Mon May 28 16:01:52 CEST 2012


Hi, 

Here i have been an matrix like this, 

*NAME    AGE   PALCE                TRUE/FALSE*
ABC         20      INDIA 
XYZ         30       FRANCE 
PQR        40       USA 
MNO     30        KENIYA 
DEF        25        AUSTRALIA 
GTY        34       CANADA
BNH      38        JAPAN

Here, *TRUE/FALSE  *Column containing empty values. 

So my requirement what is, need to change all the TRUE/FALSE column value
into "TRUE" where *AGE= 32*. 
Note :- i dont want to use any loop and do. Main intension is avoid loop,bcz
there is a bulk of data. 

Final Matrix should be like this 
*NAME    AGE   PALCE                TRUE/FALSE*
ABC         20      INDIA                     
XYZ         30       FRANCE 
PQR        40       USA 
MNO     30        KENIYA 
DEF        25        AUSTRALIA 
GTY        34       CANADA                 TRUE
BNH      38        JAPAN                     TRUE

and finally got 1 solution like this,

If "dat" is the name of your data.frame, 
dat[dat$AGE == 30,"TRUE/FALSE"] <- TRUE 

But how will use if i want to change to TRUE, *AGE between *30-to-40  ?


Immediate Help Requied 

--
View this message in context: http://r.789695.n4.nabble.com/Hash-Table-Select-and-Change-Data-iniside-Matrix-Using-Between-tp4631582.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list