Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. data = list(a=runif(n = 50, min = 1, max = 10), b=runif(n = 50, min = 1, max = 10), c=runif(n = 50, min = 1, max = 10), d=runif(n = 50, min = 1, max = 10))
  2.  
  3. var <- letters[1:length(data)]
  4. combs <- do.call(expand.grid, lapply(var, function(x) c("", x)))[-1,]
  5.  
  6. # Use the combination specified in the 5th row of combs and extract this data
  7. combs[,5] # in this case is "a", "c"
  8. # by hand it would be:
  9. res = cbind(data[["a"]], 0, data[["c"]])
  10. # apply functions to each row across all these vectors
  11.  
  12. # for combs[11,] it would be
  13. res = cbind(data[["a"]], data[["b"]], 0, data[["d"]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement