From murdoch at stats.uwo.ca  Thu Apr 17 01:46:23 2008
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 16 Apr 2008 19:46:23 -0400
Subject: [Rd] matrix
In-Reply-To: <939863.45500.qm@web46012.mail.sp1.yahoo.com>
References: <939863.45500.qm@web46012.mail.sp1.yahoo.com>
Message-ID: <48068FCF.7040804@stats.uwo.ca>

On 16/04/2008 7:33 PM, Yuan Jian wrote:
> Hello,
>   I have a matrix, I want to change value to 0 when a element in the matrix has less than 10.
>   do you know how to do it without using loops?

A[A < 10] <- 0

Remember that matrices are just vectors with dimensions, so you can 
index one like a vector.

Duncan Murdoch



[Rd] matrix
Duncan Murdoch