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

2012-06-11 Thread arun
sage - From: Curtis Burkhalter To: r-help@r-project.org Cc: Sent: Monday, June 11, 2012 3:44 PM Subject: [R] replacing values of matrix with random values of another dataframe Hello, I'm having trouble performing a certain function within R and I was hoping someone might be able to he

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

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

2012-06-11 Thread Curtis Burkhalter
Hello, I'm having trouble performing a certain function within R and I was hoping someone might be able to help. I have a matrix (1000x21) that contains whole-number values ranging from 1-7 and I want to replace all entries within this matrix that have a value of 1 with a random number contained