Hi Uwe,

 

How can we give "OR" Operator instead of "AND" here.

dat[, tmpCol] <- ifelse(dat$AGE<=35 & da$AGE>18, "YES", " ")

 

I want change this to "OR"

 

dat[, tmpCol] <- ifelse(dat$AGE<=35 OR da$AGE>18, "YES", " ")

 

"OR" - How it is possible ?

 

 

From: Uwe Ligges-3 [via R]
[mailto:ml-node+s789695n4631665...@n4.nabble.com] 
Sent: Tuesday, May 29, 2012 2:21 PM
To: Akkara, Antony (GE Energy, Non-GE)
Subject: Re: Use variable inside Function for updating the matrix

 



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. 
> 
> ______________________________________________ 
> [hidden email] 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. 


______________________________________________ 
[hidden email] 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. 



________________________________

If you reply to this email, your message will be added to the discussion
below:

http://r.789695.n4.nabble.com/Use-variable-inside-Function-for-updating-
the-matrix-tp4631663p4631665.html 

To unsubscribe from Use variable inside Function for updating the
matrix, click here
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib
e_by_code&node=4631663&code=YW50b255LmFra2FyYUBnZS5jb218NDYzMTY2M3wxNTUx
OTQzMDI5> .
NAML
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view
er&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.Bas
icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem
plate.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml
-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai
l.naml>  



--
View this message in context: 
http://r.789695.n4.nabble.com/Use-variable-inside-Function-for-updating-the-matrix-tp4631663p4631668.html
Sent from the R help mailing list archive at Nabble.com.
        [[alternative HTML version deleted]]

______________________________________________
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