Displaying 1 result from an estimated 1 matches for "m_good_initial".
2012 Jun 11
2
replacing values of matrix with random values of another dataframe
...I've tried
using the if/else function, but this always seems to return a list with
strange output. I've also tried using the "replace" and "apply" functions,
but can't seem to get anything to work. My code is as follows:
#create data frame of 21000 random values
m_good_initial=rnorm(21000,2.79,0.18)
m_good_D1=ifelse(m_good_initial<0,0,m_good_initial)
m_good_D1mat=matrix(m_good_D1,byrow=T,21)
m_good_D1=as.data.frame(m_good_D1mat)
#create matrix of (1000x21) that contains whole-number values ranging from
1-7
#using sample to select values with a respective probability...