Re: [R] replacing values of matrix with random values of another dataframe

2012-06-11 Thread arun
Hi, Not sure if this is what you want.  dat1<-matrix(sample(1:7,70,replace=TRUE),ncol=10,byrow=FALSE)  dat2<-matrix(sample(1:7,70,replace=TRUE),ncol=7,byrow=FALSE)  dat1[dat1[,1:10]==1]<-NA > dat1 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]    3    4    3    2    3    7    6   

Re: [R] replacing values of matrix with random values of another dataframe

2012-06-11 Thread Sarah Goslee
Hi Curtis, This isn't quite a reproducible example, though very close. As far as I can tell, you're over-thinking it. Instead of: bengood1=ifelse(search_strat_good==1,sample(m_good_D1,replace=F),search_strat_good) bengood1 <- search_strat_good bengood1[bengood1 == 1] <- sample(m_good_D1, size=su