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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to