0
我接下來的兩個數據幀:加盟v提供兩種dataframes用階乘組合
table_1<-data.frame(col1=round(runif(10, 1, 10)), col2=round(runif(10, 1, 10)),col3=round(runif(10, 1, 10)),col4=round(runif(10, 1, 10)),col5=round(runif(10, 1, 10)),col6=round(runif(10, 1, 10)))
table_2<-data.frame(col1=round(runif(10, 1, 10)), col2=round(runif(10, 1, 10)),col3=round(runif(10, 1, 10)),col4=round(runif(10, 1, 10)),col5=round(runif(10, 1, 10)),col5=round(runif(10, 1, 10)))
comb<-lapply(1:6, function(n) combn(names(table_1),n))
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "col1" "col2" "col3" "col4" "col5" "col6"
[[2]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] "col1" "col1" "col1" "col1" "col1" "col2" "col2" "col2" "col2" "col3" "col3" "col3" "col4" "col4"
[2,] "col2" "col3" "col4" "col5" "col6" "col3" "col4" "col5" "col6" "col4" "col5" "col6" "col5" "col6"
[,15]
[1,] "col5"
[2,] "col6"
[[3]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] "col1" "col1" "col1" "col1" "col1" "col1" "col1" "col1" "col1" "col1" "col2" "col2" "col2" "col2"
[2,] "col2" "col2" "col2" "col2" "col3" "col3" "col3" "col4" "col4" "col5" "col3" "col3" "col3" "col4"
[3,] "col3" "col4" "col5" "col6" "col4" "col5" "col6" "col5" "col6" "col6" "col4" "col5" "col6" "col5"
[,15] [,16] [,17] [,18] [,19] [,20]
[1,] "col2" "col2" "col3" "col3" "col3" "col4"
[2,] "col4" "col5" "col4" "col4" "col5" "col5"
[3,] "col6" "col6" "col5" "col6" "col6" "col6"
而我想要做的是加入使用張貼在「梳狀」所有組合的兩個表。因此,使用梳狀的第一個匹配[[1]](只有一個組合)將是:
table_1$col1=table_2$col1 or table_1$col2=table_2$col2 or table_1$col3=table_2$col3 or ....
第二組合(梳[[2]])將是
table_1$col1=table_2$col1 and table_1$col2=table_2$col2) or (table_1$col1=table_2$col1 or table_1$col3=table_2$col3) .. and so on.
誰能幫助我與此。
該腳本不適用於我。你能否以另一種格式再次寫下來?謝謝 – lolo