würde Ich mag zum Beispiel zwei data.frame
in R. verweben:verweben zwei data.frames in R
a = data.frame(x=1:5, y=5:1)
b = data.frame(x=2:6, y=4:0)
Ich würde das Ergebnis gefällt aussehen:
> x y
1 5
2 4
2 4
3 3
3 3
...
durch cbind
ing erhalten x[1]
mit y[1]
, x[2]
mit y[2]
usw.
Was ist der sauberste Weg, dies zu tun? Im Moment besteht meine Lösung darin, alles auf eine Liste zu spucken und zu verschmelzen. Das ist ziemlich hässlich:
lst = lapply(1:length(x), function(i) cbind(x[i,], y[i,]))
res = do.call(rbind, lst)