| 項目 | サンプル | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2つのテーブルを横につなげたい(最大行に合わせる) | 
  | 
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2つのテーブルを横につなげたい(最小行に合わせる) | 
  | 
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2つのテーブルをキーで結合したい | 
  | 
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 片方のテーブルを列別、下端で追加したい | 
  | 
  
 
  | 
=> | 
  | 
N = 4;
c1("C1") = {1:N};
c2("C2") = paste("a",c1);
table = cbind(c1,c2);
N2 = 6;
c3("C3") = runif(N2,1,20);
c4("C4") = shuffle({1:N2});
table2 = cbind(c3,c4);
//
defRow = cbind(-1,""); // 補間用レコード
defRow2 = cbind(-1,-1); // 補間用レコード
if (nrow(table) < nrow(table2)) {
  table = rbind(table,defRow);
} else if (nrow(table) > nrow(table2)) {
  table2 = rbind(table2,defRow2);
}
result = cbind(table,table2);
 
  | 
=> | 
  | 
N = 4;
c1("C1") = {1:N};
c2("C2") = paste("a",c1);
table = cbind(c1,c2);
N2 = 6;
c3("C3") = runif(N2,1,20);
c4("C4") = shuffle({1:N2});
table2 = cbind(c3,c4);
//
if (nrow(table) < nrow(table2)) {
  table2 = sel(row={1:nrow(table)},table2);
} else if (nrow(table) > nrow(table2)) {
  table = sel(row={1:nrow(table2)},table);
}
result = cbind(table,table2);
 
  | 
=> | 
  | 
c1("C1") = {1,    2,    2,    3,    4,    4,    4,    5,    5    };
c2("C2") = {"s10","s21","s22","s30","s40","s40","s40","s50","s60"};
table = cbind(c1,c2);
cc1("CC1") = {1,   2,   3,   4   };
cc2("CC2") = {"s1","s2","s3","s4"};
table2 = cbind(cc1,cc2);
//
key = 1;
key2 = 1;
result = merge(table, table2, "00", key, key2);
 
  | 
=> | 
 
  | 
=> | 
  | 
c1("C1") = {1,    2,    2,    3,    4,    4,    4,    5,    5    };
c2("C2") = {"s10","s21","s22","s30","s40","s40","s40","s50","s60"};
c3("C3") = {"t10","t21","t22","t30","t40","t40","t40","t50","t60"};
table1 = cbind(c1,c2,c3);
cc1("CC1") = {1,   2,   3,   4   };
cc2("CC2") = {"s1","s2","s3","s4"};
table2 = cbind(cc1,cc2);
//
key1 = 1;
key2 = 1;
defRow1(titles(table1)) = cbind(-1,"",""); // 補間用レコード
defRow2(titles(table2)) = cbind(-1,""); // 補間用レコード
defRow1_ = defRow1(sel(not row=key1,{1:ncol(defRow1)}));
defRow2_ = defRow2(sel(not row=key2,{1:ncol(defRow2)}));
table1_ = cbind(table1, rep(defRow2_,ncol(table1)));
idxList2 = sel(not row=key2,{1:ncol(table2)});
table2_ = cbind(table2(key2),rep(defRow1_,ncol(table2)),table2(idxList2));
result = rbind(table1_, table2_);