Tena koe Maria

It seems you need to multiply Flow by 0.05+ASBClass/20 (i.e., no if calls are 
necessary)

HTH ....

Peter Alspach

-----Original Message-----
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maria Lathouri
Sent: Tuesday, 15 September 2015 10:57 p.m.
To: r-help@r-project.org
Subject: [R] Multiple if function

Dear all, 

I am writing as I would like your help. I have a dataframe with two columns, 
ASB and Flow, where the the first one has values 1, 2 or 3 and the second flow 
data. Something like that:
ASBclass    Flow1              11.51               9.2
2              10.5
3               6.7  ...              ...
I would like to produce a third column named eg. deviation where it would get 
me values based on if ASBclass is 1, multiply Flow by 0.1; if ASBclass is 2 
then multiply Flow by 0.15 and if ASBclass is 3 then multiply by 0.2.

If (ASBclass=1) { deviation<-Flow*0.1}
If (ASBclass=2) { deviation<-Flow*0.15}If (ASBclass=1) { deviation<-Flow*0.2} I 
am not sure whether I should add the else function and how can I combine these 
separate functions.

Can anyone help me on that?
Thank you very much. 

Kind regardsMaria

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
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.

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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