Skip to content
Prev 257017 / 398506 Next

how to add two data.frame with the same column but different row numbers

Hi:

Here's one approach:
x y  z
1 a 1  6
2 b 2 NA
3 c 3  1
sumdf <- data.frame(x = dfm$x, y = rowSums(dfm[, -1], na.rm = TRUE))
  x y
1 a 7
2 b 2
3 c 4

HTH,
Dennis
On Fri, Apr 15, 2011 at 1:31 PM, zhenjiang xu <zhenjiang.xu at gmail.com> wrote: