[R] Multiple IF statements - is there a better alternative?

From: Jones, Glen R <Glen.Jones_at_team.telstra.com>
Date: Thu 12 May 2005 - 11:35:03 EST


Hello,

Rather than rely on a set of IF statements (as there could be many - please see below)), could the following be done in a different/better way?

InternalMean <- mean(data1[,3])

if (InternalMean == 0)

    Intresult = 1
if (InternalMean > 0 & InternalMean < 1)

    Intresult = .95
if (InternalMean >= 1 & InternalMean < 2)

    Intresult = .85
if (InternalMean >= 2 & InternalMean < 4)

    Intresult = .70
...
if (InternalMean >= 9)

    Intresult = .0

Thanks in advance

Glen Jones
Value Analyst
Industry Framework Governance
Telstra Corporation Limited
> Tel: (03) 9634 7280
email: glen.jones@team.telstra.com

> The information contained in this e-mail message may be confidential.
> If you are not the intended recipient, any use of, interference with,
> disclosure or copying of this material is unauthorised and prohibited.
> If you have received this message in error, please notify me by reply
> e-mail and then delete the message.
>

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 12 16:33:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:42 EST