1

列表数据“lt”如下。

[[1]]
"f24j"        "mirror"      "heliostat"   "reflect"     "photo"       "solar"       "sun"         
[[2]]
"imag"        "radiation"   "sens"        "detect"      
[[3]]
"mesur"       "chas"        "captur"      
...

我想从“lt”制作结果数据..

   var1      var2
 1 f24j      mirror
 2 f24j      heliostat
 3 f24j      reflect
 4 f24j      photo
 5 f24j      solar
 6 f24j      sun
 7 mirror    heliostat
 8 mirror    reflect
 9 mirror    photo
10 mirror    solar
11 mirror    sun
12 heliostat reflect
13 heliostat photo
14 heliostat solar
15 heliostat sun
16 reflect   photo
17 reflect   solar
18 reflect   sun
19 photo     solar
20 photo     sun
21 solar     sun
22 img       radiation
23 img       sens
24 img       detect
25 radiation sens
26 radiation detect
27 sens      detect
28 mesur     chas
29 mesur     captur
30 chas      captur
...

我不知道如何在 R 中得到这个结果

4

1 回答 1

2

尝试这个:

ll = list(letters[1:5], letters[6:8], letters[9:12])
ans = unlist(lapply(ll, combn, m=2, simplify=FALSE), recursive=FALSE)

使用您自己的列表代替ll.

于 2014-02-17T06:14:37.327 回答