On 29.05.2012 09:17, Rantony wrote:
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 !.


You need

dat[[Obj_Name]]  rather than dat$Obj_Name, the latter means the same as
dat[["Obj_Name"]] and hence is wrong.

Uwe Ligges




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.

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to