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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -