Skip to content
Prev 69560 / 398525 Next

Multiple IF statements - is there a better alternative?

On Thu, 12-May-2005 at 11:35AM +1000, Jones, Glen R wrote:
|> 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

?switch

HTH
Message-ID: <20050512025731.GE5776@hortresearch.co.nz>
In-Reply-To: <5D01E8305096D3119D7D00508B5EBBF4164C8EEE@ntmsg0133.corpmail.te lstra.com.au>