r - Eliminate some value from a matrix -
i want eliminate value of matrix t3 <=2 without using if, for, while, repeat. need use on larger matrix, use simple example
t1=matrix(1:3,nr=3,nc=3,byrow=false) t2=matrix(1:3,nr=3,nc=3,byrow=true) t3=matrix(t1^2+t2^2,nr=3,nc=3)
what mean "eliminate"? want change single value(s)? or want remove entire row?
this shows how change values of t3
less or equal 2 na
indexing assignment function [<-
> t3[t3 <= 2] <- na > t3 # [,1] [,2] [,3] #[1,] na 5 10 #[2,] 5 8 13 #[3,] 10 13 18
Comments
Post a Comment