[R] Hash Table - Select and Change Data iniside Matrix Using "Between"
arun
smartpink111 at yahoo.com
Mon May 28 18:36:10 CEST 2012
Hi,
I guess this is what you are looking for,
dat[dat$AGE<=40 & da$AGE>=30,"TRUE/FALSE"]<-TRUE
A.K.
----- Original Message -----
From: Rantony <antony.akkara at ge.com>
To: r-help at r-project.org
Cc:
Sent: Monday, May 28, 2012 10:01 AM
Subject: [R] Hash Table - Select and Change Data iniside Matrix Using "Between"
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.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list