Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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))
- var <- letters[1:length(data)]
- combs <- do.call(expand.grid, lapply(var, function(x) c("", x)))[-1,]
- # Use the combination specified in the 5th row of combs and extract this data
- combs[,5] # in this case is "a", "c"
- # by hand it would be:
- res = cbind(data[["a"]], 0, data[["c"]])
- # apply functions to each row across all these vectors
- # for combs[11,] it would be
- res = cbind(data[["a"]], data[["b"]], 0, data[["d"]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement