- No.03212 複数のデータフレームを併合
- [1] 「<<-」 は「永続代入」で、グローバル変数に対して代入する場合に利用するらしい
- ローカル変数と永続代入<<- R-Source http://cse.naro.affrc.go.jp/takezawa/r-tips/r/32.html
Last active
December 26, 2015 04:39
-
-
Save yuu-ito/7094938 to your computer and use it in GitHub Desktop.
Rのmerge関数で3つ以上のデータフレームを結合したかったので。
ググって見つけたものをまとめておく。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merge2 <- function(dfs, ...) | |
{ | |
# res <- merge2(list(Df1, Df2, Df3), by="ID") | |
base <- dfs[1] | |
lapply(dfs[-1], function(i) base <<- merge(base, i, ...)) # [1] | |
return(base) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment