Message-ID: <4E26DD90.9090407@gmail.com>
Date: 2011-07-20T13:52:16Z
From: Duncan Murdoch
Subject: Coercing Logical array to Numeric array
In-Reply-To: <907E6208567EDA4E8CF92FAC67F6BB810132522C8AAF@KCL-MAIL05.kclad.ds.kcl.ac.uk>
On 20/07/2011 7:14 AM, Mitra, Sumona wrote:
> Dear all,
>
> Coercing a logical vector to a numeric one is easy. The as.numeric function is used. However what do we use when we have a matrix or an array?
Usually you don't need to do anything: if a local is used in
arithmetic, the values are automatically coerced. But if you really
need the conversion, this should work:
newArray <- as.numeric(oldArray)
dim(newArray) <- dim(oldArray)
Duncan Murdoch