我有4个载体:
list1 <- c("a","b","c","d","e")
list2 <- c("f","g","h","i","j")
list3 <- c("k","l","m","n","o")
list4 <- c("p","q","r","s","t")
我想生成每个组合来选择这4个向量中的2个,所以我使用了:
combs <- combn(c("a","b","c","d"),2)
然后我想用这些组合(梳子的列)作为参数运行一个函数:
所以第1列应该给出list1和list2的组合,但是我想把它作为向量“a”,“b”,“c”,“d”,“e”,“f”,“g”, “h”,“i”,“j”而不是“list1”“list2”
答案 0 :(得分:0)
我们可以尝试
combn(paste0("list", 1:4), 2, FUN = function(x)
unlist(mget(x, envir = .GlobalEnv)))