Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. xList <- lapply(1:nCol, function(x) unique(c(x, sample(1:nCol, sample(1:nCol, 1)))))
  2.  
  3. xMatrix <- matrix(rnorm(nRow*nCol), nrow = nRow)
  4.  
  5. ################Make a new matrix based on the information of xList
  6. xMatrixNew <- xMatrix
  7.  
  8. for (ii in 1:nRow){
  9. xRow <- xMatrix[ii, ]
  10. for (jj in 1:nCol){
  11. xMatrixNew[ii, jj] <- xMatrix[ii, jj]*sum(xRow[xList[[jj]]])/sum(xRow)
  12. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement