daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(Matrix)
  2. set.seed(1)
  3. mat <- Matrix(0,5,5)
  4.    
  5. idx.mat <- do.call(rbind,lapply(1:5,function(i) sample(1:5,3,replace=F)))
  6. val.mat <- matrix(runif(15,1,10),5,3)
  7.    
  8. mat <- do.call(rbind,lapply(1:nrow(mat),function(i) {
  9.   mat[i,idx.mat[i,]] <- val.mat[i,]
  10.   return(mat[i,])
  11. }))
RAW Paste Data
Top