Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xList <- lapply(1:nCol, function(x) unique(c(x, sample(1:nCol, sample(1:nCol, 1)))))
- xMatrix <- matrix(rnorm(nRow*nCol), nrow = nRow)
- ################Make a new matrix based on the information of xList
- xMatrixNew <- xMatrix
- for (ii in 1:nRow){
- xRow <- xMatrix[ii, ]
- for (jj in 1:nCol){
- xMatrixNew[ii, jj] <- xMatrix[ii, jj]*sum(xRow[xList[[jj]]])/sum(xRow)
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement