Quantcast
Channel: かずきのBlog@hatena
Viewing all articles
Browse latest Browse all 1388

RでJOINしたい

$
0
0

merge関数を使う

> x <- data.frame(id = c(1,2,3), name = c("a", "b", "c"))
> y <- data.frame(id = c(1,2,3,4), age = c(12, 10, 11, 9))
> merge(x, y, "id")
  id name age
1  1    a  12
2  2    b  10
3  3    c  11
> merge(x, y, "id", all = T)
  id name age
1  1    a  12
2  2    b  10
3  3    c  11
4  4 <NA>   9
> 

参考

d.hatena.ne.jp


Viewing all articles
Browse latest Browse all 1388

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>