[Rd] matrix

Duncan Murdoch murdoch at stats.uwo.ca
Thu Apr 17 01:46:23 CEST 2008


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



More information about the R-devel mailing list