Re: [R] threshold and replace values in a matrix

2015-10-21 Thread Alaios via R-help
s Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios > via R-help > Sent: Wednesday, October 21, 2015 3:35 PM > To: R-help Mailing List > Subject: [R] threshold and replace values in a matrix > > Dear all I have a tabl

Re: [R] threshold and replace values in a matrix

2015-10-21 Thread PIKAL Petr
aios > via R-help > Sent: Wednesday, October 21, 2015 3:35 PM > To: R-help Mailing List > Subject: [R] threshold and replace values in a matrix > > Dear all I have a table as that. > test<-matrix(data=rnorm(100),ncol=10) > and I want to find the values that are below my thres

[R] threshold and replace values in a matrix

2015-10-21 Thread Alaios via R-help
Dear all I have a table as that. test<-matrix(data=rnorm(100),ncol=10) and I want to find the values that are below my thresholdthreshold<- -0.5and replace them with a -1 instead. I can of course write a double nested for loop to check one by one elementif (test[i,j]<= threshold)   test[i,j]<- -