df1 <- data.frame(a = c(1:5), b = c(6:10), c=c("df1","df1","df1","df1","df1")) df2 <- data.frame(a = c(1,3,5,7,9), b = c(16:20), c=c("df2","df2","df2","df2","df2"), d= LETTERS[1:5], e= LETTERS[6:10])
I would like to create a new table that does following:
- stack one table on top of the other only if the value in column a matches (i.e. 1,3,5 only)
- show only columns a, b, and c (ignore columns d and e)
- in total there should be 6 rows and 3 columns, with rows 1-3 from df1 (a=1,3,5), and rows 4-6 from df2 (a=1,3,5)
没有评论:
发表评论