[R] Use variable inside Function for updating the matrix
Rantony
antony.akkara at ge.com
Tue May 29 09:17:57 CEST 2012
Hi,
Here i have a data frame like this,
frame name is "dat"
*NAME AGE ELIGIBLE*
A 20
B 14
C 35
D 10
E 50
In this, i want to change the column '*ELIGIBLE*' status to '*YES*' If, AGE
between 18 to 35
Which means that, i should get a put like this...
*NAME AGE ELIGIBLE*
A 20 YES
B 14
C 35 YES
D 10
E 50
----------------------------------------------
Now i got the solution for this,
dat[dat$AGE<=35 & da$AGE>18,"ELIGIBLE"]<-YES
My issue is, i assigned AGE to a variable and that variable i tried inside
the function.
for eg:-
*Obj_Name* <- AGE
dat[dat$*Obj_Name*<=35 & da$*Obj_Name*>18,"ELIGIBLE"]<-YES
Now, what is i getting the error !.
So,could you please help me, what is the solution *pass column name through
*variable to this function ?
Can i get immediate solution please ?
- Thanks
Antony
--
View this message in context: http://r.789695.n4.nabble.com/Use-variable-inside-Function-for-updating-the-matrix-tp4631663.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list